Components
Segment group

Segment Group

The SegmentGroup component offers an effective way to organize and navigate between multiple sections within a single view. It provides a clear and compact option to improve usability and accessibility.

Usage

Start by importing the necessary components from the package:

import {
  Segment,
  SegmentControl,
  SegmentGroup,
  SegmentGroupIndicator,
  SegmentLabel,
} from '@ark-ui/react'

Here are some examples of how to use the SegmentGroup component:

import { SegmentGroup } from '@ark-ui/react'

const Basic = () => {
  const frameworks = ['React', 'Solid', 'Vue']
  return (
    <SegmentGroup.Root>
      <SegmentGroup.Indicator />
      {frameworks.map((framework) => (
        <SegmentGroup.Item key={framework} value={framework}>
          <SegmentGroup.ItemText>{framework}</SegmentGroup.ItemText>
          <SegmentGroup.ItemControl />
        </SegmentGroup.Item>
      ))}
    </SegmentGroup.Root>
  )
}

Initial Value

To set a default segment on initial render, use the defaultValue prop:

Story not available

Controlled SegmentGroup

To create a controlled SegmentGroup component, manage the current selected segment using the value prop and update it when the onChange event handler is called:

Story not available

Disabled Segment

To disable a segment, simply pass the disabled prop to the Segment component:

Story not available

Conclusion

The SegmentGroup component provides a versatile and adaptable solution for introducing segmented navigation to your applications. With a broad variety of customization options and features, it can cater to various use cases and designs.

Previous

Rating Group

Next

Select