File tree Expand file tree Collapse file tree 3 files changed +67
-6
lines changed
ui-webc/src/components/segmented-control Expand file tree Collapse file tree 3 files changed +67
-6
lines changed Original file line number Diff line number Diff line change 1+ import {
2+ Meta ,
3+ Controls ,
4+ Description ,
5+ Primary ,
6+ Source ,
7+ Stories ,
8+ Subtitle ,
9+ Title ,
10+ } from ' @storybook/addon-docs/blocks' ;
11+
12+ import * as SegmentedControlStories from ' ./segmented-control.stories' ;
13+
14+ <Meta of = { SegmentedControlStories } />
15+
16+ <Title />
17+ <Subtitle />
18+ <Description />
19+ <Primary />
20+ <Controls />
21+
22+ ## Code Examples
23+
24+ ### Controlling state
25+
26+ You must manage the state of the active segment yourself by listening to the
27+ ` scoutChange ` event and updating the ` value ` prop accordingly.
28+
29+ <Source
30+ language = " tsx"
31+ code = { `
32+ import { useState } from "react";
33+ import { ScoutSegmentedControl } from "@scouterna/ui-react";
34+
35+ const [activeSegment, setActiveSegment] = useState(0);
36+
37+ return (
38+ <ScoutSegmentedControl
39+ value={activeSegment}
40+ onScoutChange={(e) => setActiveSegment(e.detail.value)}
41+ >
42+ <button type="button">Alla</button>
43+ <button type="button">Bokade</button>
44+ </ScoutSegmentedControl>
45+ );
46+ ` }
47+ />
48+
49+ ## Stories
50+
51+ <Stories title = { false } />
Original file line number Diff line number Diff line change 55
66## Overview
77
8- The segmented control component is used to create a segmented interface. It
9- manages the state of which segment is active and displays an indicator under
10- the active segment. Use button elements to define the individual segments.
8+ The segmented control component presents a set of options where exactly one
9+ option is active at a time.
10+
11+ The component displays an indicator under the selected option and emits a
12+ ` scoutChange ` event when the user picks a different option, so you can update
13+ ` value ` .
14+
15+ Use button elements as the slotted segment options.
1116
1217## Properties
1318
Original file line number Diff line number Diff line change @@ -15,9 +15,14 @@ import {
1515export type Size = "small" | "medium" ;
1616
1717/**
18- * The segmented control component is used to create a segmented interface. It
19- * manages the state of which segment is active and displays an indicator under
20- * the active segment. Use button elements to define the individual segments.
18+ * The segmented control component presents a set of options where exactly one
19+ * option is active at a time.
20+ *
21+ * The component displays an indicator under the selected option and emits a
22+ * `scoutChange` event when the user picks a different option, so you can update
23+ * `value`.
24+ *
25+ * Use button elements as the slotted segment options.
2126 */
2227@Component ( {
2328 tag : "scout-segmented-control" ,
You can’t perform that action at this time.
0 commit comments