Segmented

Segmented Props

NameTypeDefaultDescription

colors

object

Object with Tailwind CSS colors classes

colors.borderIos

string

'border-primary'

colors.borderMaterial

string

'border-md-light-outline dark:border-md-dark-outline'

colors.divideIos

string

'divide-primary'

colors.divideMaterial

string

'divide-md-light-outline dark:divide-md-dark-outline'

colors.strongBgIos

string

'bg-black bg-opacity-5 dark:bg-white dark:bg-opacity-10'

colors.strongBgMaterial

string

'bg-md-light-surface-variant dark:bg-md-dark-surface-variant'

component

string

'div'

Component's HTML Element

outline

boolean

false

Makes segmented outline

raised

boolean

false

Makes segmented raised

rounded

boolean

false

Makes segmented rounded

strong

boolean

false

Makes segmented strong

SegmentedButton Props

SegmentedButton component extends Button component, it supports all Button props and the following additional props:

NameTypeDefaultDescription

active

boolean

false

Highlights button as active

component

string

'button'

Component's HTML Element

rounded

boolean

false

Makes segmented button rounded (should be used within <Segmented rounded>)

strong

boolean

false

Makes strong segmented button (should be used within <Segmented strong>)

Examples

<template>
  <i-page>
    <i-navbar title="Segmented Control" />

    <i-block-title>Default Segmented</i-block-title>
    <i-block strong-ios outline-ios class="space-y-4">
      <i-segmented>
        <i-segmented-button
          :active="activeSegmented === 1"
          @click="() => (activeSegmented = 1)"
        >
          Button
        </i-segmented-button>
        <i-segmented-button
          :active="activeSegmented === 2"
          @click="() => (activeSegmented = 2)"
        >
          Button
        </i-segmented-button>
        <i-segmented-button
          :active="activeSegmented === 3"
          @click="() => (activeSegmented = 3)"
        >
          Button
        </i-segmented-button>
      </i-segmented>

      <i-segmented rounded>
        <i-segmented-button
          :active="activeSegmented === 1"
          @click="() => (activeSegmented = 1)"
        >
          Button
        </i-segmented-button>
        <i-segmented-button
          :active="activeSegmented === 2"
          @click="() => (activeSegmented = 2)"
        >
          Button
        </i-segmented-button>
        <i-segmented-button
          :active="activeSegmented === 3"
          @click="() => (activeSegmented = 3)"
        >
          Button
        </i-segmented-button>
      </i-segmented>
    </i-block>

    <i-block-title>Raised Segmented</i-block-title>
    <i-block strong-ios outline-ios class="space-y-4">
      <i-segmented raised>
        <i-segmented-button
          :active="activeSegmented === 1"
          @click="() => (activeSegmented = 1)"
        >
          Button
        </i-segmented-button>
        <i-segmented-button
          :active="activeSegmented === 2"
          @click="() => (activeSegmented = 2)"
        >
          Button
        </i-segmented-button>
        <i-segmented-button
          :active="activeSegmented === 3"
          @click="() => (activeSegmented = 3)"
        >
          Button
        </i-segmented-button>
      </i-segmented>
      <i-segmented raised rounded>
        <i-segmented-button
          :active="activeSegmented === 1"
          @click="() => (activeSegmented = 1)"
        >
          Button
        </i-segmented-button>
        <i-segmented-button
          :active="activeSegmented === 2"
          @click="() => (activeSegmented = 2)"
        >
          Button
        </i-segmented-button>
        <i-segmented-button
          :active="activeSegmented === 3"
          @click="() => (activeSegmented = 3)"
        >
          Button
        </i-segmented-button>
      </i-segmented>
    </i-block>

    <i-block-title>Outline</i-block-title>
    <i-block strong-ios outline-ios class="space-y-4">
      <i-segmented outline>
        <i-segmented-button
          :active="activeSegmented === 1"
          @click="() => (activeSegmented = 1)"
        >
          Button
        </i-segmented-button>
        <i-segmented-button
          :active="activeSegmented === 2"
          @click="() => (activeSegmented = 2)"
        >
          Button
        </i-segmented-button>
        <i-segmented-button
          :active="activeSegmented === 3"
          @click="() => (activeSegmented = 3)"
        >
          Button
        </i-segmented-button>
      </i-segmented>
      <i-segmented rounded outline>
        <i-segmented-button
          :active="activeSegmented === 1"
          @click="() => (activeSegmented = 1)"
        >
          Button
        </i-segmented-button>
        <i-segmented-button
          :active="activeSegmented === 2"
          @click="() => (activeSegmented = 2)"
        >
          Button
        </i-segmented-button>
        <i-segmented-button
          :active="activeSegmented === 3"
          @click="() => (activeSegmented = 3)"
        >
          Button
        </i-segmented-button>
      </i-segmented>
    </i-block>

    <i-block-title>Strong Segmented</i-block-title>
    <i-block strong-ios outline-ios class="space-y-4">
      <i-segmented strong>
        <i-segmented-button
          strong
          :active="activeSegmented === 1"
          @click="() => (activeSegmented = 1)"
        >
          Button
        </i-segmented-button>
        <i-segmented-button
          strong
          :active="activeSegmented === 2"
          @click="() => (activeSegmented = 2)"
        >
          Button
        </i-segmented-button>
        <i-segmented-button
          strong
          :active="activeSegmented === 3"
          @click="() => (activeSegmented = 3)"
        >
          Button
        </i-segmented-button>
      </i-segmented>

      <i-segmented strong rounded>
        <i-segmented-button
          strong
          rounded
          :active="activeSegmented === 1"
          @click="() => (activeSegmented = 1)"
        >
          Button
        </i-segmented-button>
        <i-segmented-button
          strong
          rounded
          :active="activeSegmented === 2"
          @click="() => (activeSegmented = 2)"
        >
          Button
        </i-segmented-button>
        <i-segmented-button
          strong
          rounded
          :active="activeSegmented === 3"
          @click="() => (activeSegmented = 3)"
        >
          Button
        </i-segmented-button>
      </i-segmented>
    </i-block>
  </i-page>
</template>
<script>
  import { ref } from 'vue';
  import {
    iPage,
    iNavbar,
    iNavbarBackLink,
    iSegmented,
    iSegmentedButton,
    iBlock,
    iBlockTitle,
  } from 'ina-ui/vue';

  export default {
    components: {
      iPage,
      iNavbar,
      iNavbarBackLink,
      iSegmented,
      iSegmentedButton,
      iBlock,
      iBlockTitle,
    },
    setup() {
      const activeSegmented = ref(1);
      return {
        activeSegmented,
      };
    },
  };
</script>

Last updated