🔥 新しいプロジェクトのご紹介 t0ggles -究極のプロジェクト管理ツール! 🔥

セグメントコントロール Vue コンポーネント

セグメントコントロールは、相互に排他的なボタンとして機能する2つ以上のセグメント(ボタン)の線形セットです。コントロール内では、すべてのボタンの幅は均一です。セグメントコントロールは、異なるビューを表示する(タブを切り替える)ために頻繁に使用されます。

セグメントコンポーネント

以下のコンポーネントが含まれています。

  • Segmented - ボタン用のセグメントラッパー
  • SegmentedButton - 単一のセグメントボタン

セグメントプロパティ

名前デフォルト説明
colorsオブジェクト

Tailwind CSS カラークラスを持つオブジェクト

colors.borderIos文字列'border-primary'
colors.borderMaterial文字列'border-md-light-outline dark:border-md-dark-outline'
colors.divideIos文字列'divide-primary'
colors.divideMaterial文字列'divide-md-light-outline dark:divide-md-dark-outline'
colors.strongBgIos文字列'bg-black bg-opacity-5 dark:bg-white dark:bg-opacity-10'
colors.strongBgMaterial文字列'bg-md-light-surface-variant dark:bg-md-dark-surface-variant'
component文字列'div'

コンポーネントのHTML要素

outlineブール値false

セグメントアウトラインを作成します

raisedブール値false

セグメントを立体的にします

roundedブール値false

セグメントを丸くします

strongブール値false

セグメントを強調表示します

SegmentedButton プロパティ

SegmentedButton コンポーネントはButton コンポーネントを拡張し、すべてのButton プロパティと以下の追加プロパティをサポートしています。

名前デフォルト説明
activeブール値false

ボタンをアクティブとして強調表示します

component文字列'button'

コンポーネントのHTML要素

roundedブール値false

セグメントボタンを丸くします (<Segmented rounded> 内で使用してください)

strongブール値false

セグメントボタンを強調表示します (<Segmented strong> 内で使用してください)

SegmentedControl.vue
<template>
<k-page>
<k-navbar title="Segmented Control" />
<k-block-title>Default Segmented</k-block-title>
<k-block strong-ios outline-ios class="space-y-4">
<k-segmented>
<k-segmented-button
:active="activeSegmented === 1"
@click="() => (activeSegmented = 1)"
>
Button
</k-segmented-button>
<k-segmented-button
:active="activeSegmented === 2"
@click="() => (activeSegmented = 2)"
>
Button
</k-segmented-button>
<k-segmented-button
:active="activeSegmented === 3"
@click="() => (activeSegmented = 3)"
>
Button
</k-segmented-button>
</k-segmented>
<k-segmented rounded>
<k-segmented-button
:active="activeSegmented === 1"
@click="() => (activeSegmented = 1)"
>
Button
</k-segmented-button>
<k-segmented-button
:active="activeSegmented === 2"
@click="() => (activeSegmented = 2)"
>
Button
</k-segmented-button>
<k-segmented-button
:active="activeSegmented === 3"
@click="() => (activeSegmented = 3)"
>
Button
</k-segmented-button>
</k-segmented>
</k-block>
<k-block-title>Raised Segmented</k-block-title>
<k-block strong-ios outline-ios class="space-y-4">
<k-segmented raised>
<k-segmented-button
:active="activeSegmented === 1"
@click="() => (activeSegmented = 1)"
>
Button
</k-segmented-button>
<k-segmented-button
:active="activeSegmented === 2"
@click="() => (activeSegmented = 2)"
>
Button
</k-segmented-button>
<k-segmented-button
:active="activeSegmented === 3"
@click="() => (activeSegmented = 3)"
>
Button
</k-segmented-button>
</k-segmented>
<k-segmented raised rounded>
<k-segmented-button
:active="activeSegmented === 1"
@click="() => (activeSegmented = 1)"
>
Button
</k-segmented-button>
<k-segmented-button
:active="activeSegmented === 2"
@click="() => (activeSegmented = 2)"
>
Button
</k-segmented-button>
<k-segmented-button
:active="activeSegmented === 3"
@click="() => (activeSegmented = 3)"
>
Button
</k-segmented-button>
</k-segmented>
</k-block>
<k-block-title>Outline</k-block-title>
<k-block strong-ios outline-ios class="space-y-4">
<k-segmented outline>
<k-segmented-button
:active="activeSegmented === 1"
@click="() => (activeSegmented = 1)"
>
Button
</k-segmented-button>
<k-segmented-button
:active="activeSegmented === 2"
@click="() => (activeSegmented = 2)"
>
Button
</k-segmented-button>
<k-segmented-button
:active="activeSegmented === 3"
@click="() => (activeSegmented = 3)"
>
Button
</k-segmented-button>
</k-segmented>
<k-segmented rounded outline>
<k-segmented-button
:active="activeSegmented === 1"
@click="() => (activeSegmented = 1)"
>
Button
</k-segmented-button>
<k-segmented-button
:active="activeSegmented === 2"
@click="() => (activeSegmented = 2)"
>
Button
</k-segmented-button>
<k-segmented-button
:active="activeSegmented === 3"
@click="() => (activeSegmented = 3)"
>
Button
</k-segmented-button>
</k-segmented>
</k-block>
<k-block-title>Strong Segmented</k-block-title>
<k-block strong-ios outline-ios class="space-y-4">
<k-segmented strong>
<k-segmented-button
strong
:active="activeSegmented === 1"
@click="() => (activeSegmented = 1)"
>
Button
</k-segmented-button>
<k-segmented-button
strong
:active="activeSegmented === 2"
@click="() => (activeSegmented = 2)"
>
Button
</k-segmented-button>
<k-segmented-button
strong
:active="activeSegmented === 3"
@click="() => (activeSegmented = 3)"
>
Button
</k-segmented-button>
</k-segmented>
<k-segmented strong rounded>
<k-segmented-button
strong
rounded
:active="activeSegmented === 1"
@click="() => (activeSegmented = 1)"
>
Button
</k-segmented-button>
<k-segmented-button
strong
rounded
:active="activeSegmented === 2"
@click="() => (activeSegmented = 2)"
>
Button
</k-segmented-button>
<k-segmented-button
strong
rounded
:active="activeSegmented === 3"
@click="() => (activeSegmented = 3)"
>
Button
</k-segmented-button>
</k-segmented>
</k-block>
</k-page>
</template>
<script>
import { ref } from 'vue';
import {
kPage,
kNavbar,
kNavbarBackLink,
kSegmented,
kSegmentedButton,
kBlock,
kBlockTitle,
} from 'konsta/vue';
export default {
components: {
kPage,
kNavbar,
kNavbarBackLink,
kSegmented,
kSegmentedButton,
kBlock,
kBlockTitle,
},
setup() {
const activeSegmented = ref(1);
return {
activeSegmented,
};
},
};
</script>
ライセンス MIT.
2022 © Konsta UI by nolimits4web.