@@ -87,65 +87,111 @@ provide(NC_FORM_BOX_CONTEXT_KEY, {
8787<docs >
8888### General
8989
90- Visually group form elements with a small gap and rounded corners forming a solid group for supported components .
90+ A container of supported components with a small gap and rounded corners forming a solid group.
9191
92- **Note**: if the group has a semantic meaning, consider using the `<NcFormGroup>` component.
92+ Currently supported components:
93+ - **`<NcFormBoxButton>`**: an action button/link with an optional description specially for the `<NcFormBox>` context
94+ - **`<NcFormBoxCopyButton>`**: a special case of a button to copy a text to the clipboard
95+ - **`<NcFormBoxSwitch>`**: a toggle switch replacing `<NcCheckboxRadioSwitch type="switch">` in a box
96+ - **`<NcButton>`**: a general button in case there is a kind of primary action within a box
97+
98+ **Note**: if the group has a semantic meaning, consider wrapping the `<NcFormBox>` into `<NcFormGroup>` component with a label.
9399
94100```vue
95101<script>
102+ import { mdiArrowRight, mdiFolderOpenOutline, mdiPlus } from '@mdi/js'
103+
96104export default {
105+ setup() {
106+ return { mdiArrowRight, mdiFolderOpenOutline, mdiPlus }
107+ },
108+
97109 data() {
98110 return {
99111 text: 'Text',
100- option: 'One'
112+ switchValue: false,
101113 }
102- }
114+ },
103115}
104116</script>
105117
106118<template>
107- <NcFormBox>
108- <NcTextField v-model="text" label="Text Field" />
109- <NcTextField v-model="text" label="Text Field" />
110- <NcTextField v-model="text" label="Text Field" />
111- <NcSelect v-model="option" input-label="Select Field" :options="['One', 'Two', 'Three']" />
112- </NcFormBox>
119+ <div style="display: flex; flex-direction: column; gap: calc(6 * var(--default-grid-baseline));">
120+ <NcFormBox>
121+ <NcFormBoxCopyButton label="WebDAV URL" value="https://cloud.example.tld/remote.php/dav/files/user" />
122+ </NcFormBox>
123+
124+ <NcFormGroup label="Account settings">
125+ <NcFormBox>
126+ <NcFormBoxButton label="user@example.com">
127+ <template #icon>
128+ <NcIconSvgWrapper :path="mdiArrowRight" inline />
129+ </template>
130+ </NcFormBoxButton>
131+ <NcFormBoxButton label="sales@example.com">
132+ <template #icon>
133+ <NcIconSvgWrapper :path="mdiArrowRight" inline />
134+ </template>
135+ </NcFormBoxButton>
136+ <NcButton wide>
137+ <template #icon>
138+ <NcIconSvgWrapper :path="mdiPlus" />
139+ </template>
140+ Add mail account
141+ </NcButton>
142+ </NcFormBox>
143+ </NcFormGroup>
144+
145+ <NcFormGroup label="Device settings">
146+ <NcFormBox>
147+ <NcFormBoxSwitch v-model="switchValue" label="Turn camera and microphone off by default" />
148+ <NcFormBoxSwitch v-model="switchValue" label="Blur camera background by default" />
149+ <NcFormBoxSwitch
150+ v-model="switchValue"
151+ label="Skip device preview before joining a call"
152+ description="Will always show if recording consent is required" />
153+ </NcFormBox>
154+ </NcFormGroup>
155+
156+ <NcFormBox>
157+ <NcFormBoxButton
158+ label="Attachments folder"
159+ description="/Talk"
160+ inverted-accent>
161+ <template #icon>
162+ <NcIconSvgWrapper :path="mdiFolderOpenOutline" inline />
163+ </template>
164+ </NcFormBoxButton>
165+ </NcFormBox>
166+ </div>
113167</template>
114168```
115169
116170### Advanced usage
117171
118- Use scoped slots params to apply the item class to custom items.
172+ Scoped slot prop `itemClass` can be used to apply the same border radius effect to custom components.
173+ Create an issue if you need a composable to inject the class into a custom component.
119174
120175```vue
121176<template>
122- <div>
123- <h4>NcButton without a group</h4>
124- <div>
125- <NcButton wide>
126- First button
127- </NcButton>
128- <NcButton wide>
129- Second button
130- </NcButton>
131- <NcButton wide>
132- Third button
133- </NcButton>
134- </div>
135-
136- <h4>NcButton inside NcFormBox with scoped-slot</h4>
137- <NcFormBox v-slot="{ itemClass }">
138- <NcButton :class="itemClass" wide>
139- First button
140- </NcButton>
141- <NcButton :class="itemClass" wide>
142- Second button
143- </NcButton>
144- <NcButton :class="itemClass" wide>
145- Third button
146- </NcButton>
147- </NcFormBox>
148- </div>
177+ <NcFormBox v-slot="{ itemClass }">
178+ <button class="native-button" :class="itemClass">
179+ First native button
180+ </button>
181+ <button class="native-button" :class="itemClass">
182+ Second native button
183+ </button>
184+ <button class="native-button" :class="itemClass">
185+ Third native button
186+ </button>
187+ </NcFormBox>
149188</template>
189+
190+ <style scoped>
191+ .native-button {
192+ /* Remove default server margin around a native button */
193+ margin: 0 !important;
194+ }
195+ </style>
150196```
151197</docs >
0 commit comments