Demos
Value
Oslo, Stockholm og Copenhagen
<Value.MultiSelection value={['Oslo', 'Stockholm', 'Copenhagen']} />
Field.MultiSelection with path
When using the same path as on a Field.MultiSelection, titles are resolved automatically via field internals.
const cities = [ { value: 'oslo', title: 'Oslo', }, { value: 'stockholm', title: 'Stockholm', }, { value: 'copenhagen', title: 'Copenhagen', }, { value: 'helsinki', title: 'Helsinki', }, { value: 'reykjavik', title: 'Reykjavik', }, ] render( <Form.Handler> <Flex.Stack> <Value.MultiSelection inheritLabel path="/myPath" placeholder="No cities selected" /> <Field.MultiSelection label="Select cities" path="/myPath" data={cities} /> </Flex.Stack> </Form.Handler> )
With data prop
Resolve values to titles using the data prop.
Oslo og Copenhagen
const cities = [ { value: 'oslo', title: 'Oslo', }, { value: 'stockholm', title: 'Stockholm', }, { value: 'copenhagen', title: 'Copenhagen', }, ] render( <Value.MultiSelection value={['oslo', 'copenhagen']} data={cities} /> )
With dataPath
Use dataPath to resolve titles from the data context without rendering a Field.MultiSelection.
<Form.Handler data={{ myItems: [ { value: 'oslo', title: 'Oslo', }, { value: 'stockholm', title: 'Stockholm', }, { value: 'copenhagen', title: 'Copenhagen', }, ], myPath: ['oslo', 'copenhagen'], }} > <Value.MultiSelection label="Selected cities" path="/myPath" dataPath="/myItems" /> </Form.Handler>
Inline
This is before the component Oslo, Stockholm og Copenhagen This is after the component
<P> This is before the component{' '} <Value.MultiSelection value={['Oslo', 'Stockholm', 'Copenhagen']} inline />{' '} This is after the component </P>
List variants
- Ordered List
- Oslo
- Stockholm
- Copenhagen
- Unordered List
- Oslo
- Stockholm
- Copenhagen
<Value.SummaryList> <Value.MultiSelection value={['Oslo', 'Stockholm', 'Copenhagen']} label="Ordered List" variant="ol" /> <Value.MultiSelection value={['Oslo', 'Stockholm', 'Copenhagen']} label="Unordered List" variant="ul" /> </Value.SummaryList>