Back to Element Plus

Segmented

docs/en-US/component/segmented.md

2.13.73.9 KB
Original Source

Segmented

Display multiple options and allow users to select a single option.

Basic Usage

Set v-model to the option value is selected.

:::demo

segmented/basic

:::

Direction Usage ^(2.8.7)

Set vertical to change direction.

:::demo

segmented/custom-direction

:::

Disabled

Set disabled of segmented or option to true to disable it.

:::demo

segmented/disabled

:::

Aliases for custom options ^(2.9.8)

When your options format is different from the default format, you can customize the alias of the options through the props attribute

:::demo

segmented/props

:::

Block

Set block to true to fit the width of parent element.

:::demo

segmented/block

:::

Custom Content

Set default slot to render custom content.

:::demo

segmented/custom-content

:::

Custom Style

Set custom styles using CSS variables.

:::demo

segmented/custom-style

:::

API

Attributes

NameDescriptionTypeDefault
model-value / v-modelbinding value^[string] / ^[number] / ^[boolean]
optionsdata of the options^[array]Option[][]
props ^(2.9.8)configuration options, see the following table^[object]
sizesize of component^[enum]'' | 'large' | 'default' | 'small'''
blockfit width of parent content^[boolean]false
disabledwhether segmented is disabled^[boolean]false
validate-eventwhether to trigger form validation^[boolean]true
namenative name attribute^[string]
idnative id attribute^[string]
aria-label ^(a11y)native aria-label attribute^[string]
direction ^(2.8.7)display direction^[enum]'horizontal' | 'vertical'horizontal

props

AttributeDescriptionTypeDefault
valuespecify which key of node object is used as the node's value^[string]value
labelspecify which key of node object is used as the node's label^[string]label
disabledspecify which key of node object is used as the node's disabled^[string]disabled

Events

NameDescriptionType
changetriggers when the selected value changes, the param is current selected value^[Function](val: any) => void

Slots

NameDescriptionType
defaultoption renderer^[object]{ item: Option }

Type Declarations

<details> <summary>Show declarations</summary>
ts
type Option = Record<string, any> | string | number | boolean
</details>