<SegmentedControl aria-label="File view"><SegmentedControl.Button selected>Preview</SegmentedControl.Button><SegmentedControl.Button>Raw</SegmentedControl.Button><SegmentedControl.Button>Blame</SegmentedControl.Button></SegmentedControl>
<SegmentedControl aria-label="File view"><SegmentedControl.Button selected leadingIcon={EyeIcon}>Preview</SegmentedControl.Button><SegmentedControl.Button leadingIcon={FileCodeIcon}>Raw</SegmentedControl.Button><SegmentedControl.Button leadingIcon={PeopleIcon}>Blame</SegmentedControl.Button></SegmentedControl>
<SegmentedControl aria-label="File view"><SegmentedControl.IconButton selected icon={EyeIcon} aria-label="Preview" /><SegmentedControl.IconButton icon={FileCodeIcon} aria-label="Raw" /><SegmentedControl.IconButton icon={PeopleIcon} aria-label="Blame" /></SegmentedControl>
<SegmentedControl aria-label="File view" variant={{narrow: 'hideLabels', regular: 'none'}}><SegmentedControl.Button selected leadingIcon={EyeIcon}>Preview</SegmentedControl.Button><SegmentedControl.Button leadingIcon={FileCodeIcon}>Raw</SegmentedControl.Button><SegmentedControl.Button leadingIcon={PeopleIcon}>Blame</SegmentedControl.Button></SegmentedControl>
<SegmentedControl aria-label="File view" variant={{narrow: 'dropdown', regular: 'none'}}><SegmentedControl.Button selected leadingIcon={EyeIcon}>Preview</SegmentedControl.Button><SegmentedControl.Button leadingIcon={FileCodeIcon}>Raw</SegmentedControl.Button><SegmentedControl.Button leadingIcon={PeopleIcon}>Blame</SegmentedControl.Button></SegmentedControl>
<SegmentedControl fullWidth aria-label="File view"><SegmentedControl.Button selected>Preview</SegmentedControl.Button><SegmentedControl.Button>Raw</SegmentedControl.Button><SegmentedControl.Button>Blame</SegmentedControl.Button></SegmentedControl>
<SegmentedControl loading aria-label="File view"><SegmentedControl.Button selected>Preview</SegmentedControl.Button><SegmentedControl.Button>Raw</SegmentedControl.Button><SegmentedControl.Button>Blame</SegmentedControl.Button></SegmentedControl>
<Box display="flex"><Box flexGrow={1}><Text fontSize={2} fontWeight="bold" id="scLabel-vert" display="block">File view</Text><Text color="fg.subtle" fontSize={1} id="scCaption-vert" display="block">Change the way the file is viewed</Text></Box><SegmentedControl aria-labelledby="scLabel-vert" aria-describedby="scCaption-vert"><SegmentedControl.Button selected>Preview</SegmentedControl.Button><SegmentedControl.Button>Raw</SegmentedControl.Button><SegmentedControl.Button>Blame</SegmentedControl.Button></SegmentedControl></Box>
<FormControl><FormControl.Label id="scLabel-horiz">File view</FormControl.Label><SegmentedControl aria-labelledby="scLabel-horiz" aria-describedby="scCaption-horiz"><SegmentedControl.Button selected>Preview</SegmentedControl.Button><SegmentedControl.Button>Raw</SegmentedControl.Button><SegmentedControl.Button>Blame</SegmentedControl.Button></SegmentedControl><FormControl.Caption id="scCaption-horiz">Change the way the file is viewed</FormControl.Caption></FormControl>
<SegmentedControl aria-label="File view"><SegmentedControl.Button selected>Preview</SegmentedControl.Button><SegmentedControl.Button selected>Raw</SegmentedControl.Button><SegmentedControl.Button>Blame</SegmentedControl.Button></SegmentedControl>
<SegmentedControlaria-label="File view"onChange={selectedIndex => {alert(`Segment ${selectedIndex}`)}}><SegmentedControl.Button>Preview</SegmentedControl.Button><SegmentedControl.Button>Raw</SegmentedControl.Button><SegmentedControl.Button>Blame</SegmentedControl.Button></SegmentedControl>
Name | Type | Default | Description |
---|---|---|---|
aria-label | string | ||
aria-labelledby | string | ||
aria-describedby | string | ||
fullWidth | boolean | Whether the control fills the width of its parent | |
loading | boolean | Whether the selected segment is being calculated | |
onChange Required | (selectedIndex?: number) => void | The handler that gets called when a segment is selected | |
variant | { narrow?: 'hideLabels' | 'dropdown', regular?: 'hideLabels' | 'dropdown', wide?: 'hideLabels' | 'dropdown' } | Configure alternative ways to render the control when it gets rendered in tight spaces | |
sx | SystemStyleObject | Style overrides to apply to the component. See also overriding styles. | |
ref | React.RefObject<HTMLDivElement> | A ref to the element rendered by this component. |
Name | Type | Default | Description |
---|---|---|---|
leadingIcon | Component | The leading icon comes before item label | |
selected | boolean | Whether the segment is selected | |
sx | SystemStyleObject | Style overrides to apply to the component. See also overriding styles. | |
ref | React.RefObject<HTMLButtonElement> | A ref to the element rendered by this component. |
Name | Type | Default | Description |
---|---|---|---|
aria-label Required | string | ||
icon Required | Component | The icon that represents the segmented control item | |
selected | boolean | Whether the segment is selected | |
sx | SystemStyleObject | Style overrides to apply to the component. See also overriding styles. | |
ref | React.RefObject<HTMLButtonElement> | A ref to the element rendered by this component. |