Skip to content

useButtonGroup

This requires the following keys to be installed:

This requires the following types to be installed:

useButtonGroup

ts
import type { GetObjectField } from '@/ui/utils/utils'
import { buttonGroupInjectionKey } from '@/ui/keys/button-group'
import { computed, inject } from 'vue'

interface Props<T> {
  size?: GetObjectField<T, 'size'>
}

export function useButtonGroup<T>(props: Props<T>) {
  const buttonGroup = inject(buttonGroupInjectionKey, undefined)
  return {
    orientation: computed(() => buttonGroup?.value.orientation),
    size: computed(() => props?.size ?? buttonGroup?.value.size),
  }
}
ts
import type { GetObjectField } from '@/UI/Utils/utils'
import { buttonGroupInjectionKey } from '@/UI/Keys/button-group'
import { computed, inject } from 'vue'

interface Props<T> {
  size?: GetObjectField<T, 'size'>
}

export function useButtonGroup<T>(props: Props<T>) {
  const buttonGroup = inject(buttonGroupInjectionKey, undefined)
  return {
    orientation: computed(() => buttonGroup?.value.orientation),
    size: computed(() => props?.size ?? buttonGroup?.value.size),
  }
}