@pikas-ui/toggle-group

This package contains a toggle group component that can be used to display a group of clickable items.

This library is based on Radix Ui.

Change Log

Requirements

To use this package, you must install the @pikas-ui/styles package.

Installation

You can install this package using npm, yarn, or pnpm.

npm install @pikas-ui/toggle-group
yarn add @pikas-ui/toggle-group
pnpm add @pikas-ui/toggle-group

Usage

ToggleGroup

This component is used to create a toggleGroup component.

import { ToggleGroup, ToggleGroupData } from '@pikas-ui/toggle-group';
import { IconByName, IconProps } from '@pikas-ui/icons';
import { FC } from 'react';

const IconBaguetteExample: FC<IconProps> = (props) => (
  <IconByName {...props} name="bx:baguette" />
);

const IconBowlRiceExample: FC<IconProps> = (props) => (
  <IconByName {...props} name="bx:bowl-rice" />
);

const IconCookieExample: FC<IconProps> = (props) => (
  <IconByName {...props} name="bx:cookie" />
);

const data: ToggleGroupData[] = [
  {
    value: 'baguette',
    Icon: IconBaguetteExample,
  },
  {
    value: 'bowl-rice',
    Icon: IconBowlRiceExample,
  },
  {
    value: 'cookie',
    Icon: IconCookieExample,
    disabled: true,
  },
]

const Example: React.FC = () => {
  return (
    <ToggleGroup
      type="single"
      data={data}
      defaultValue="baguette"
      onValueChange={(value) => console.log(value)}
    />
  );
};

Props

PropDescriptionTypeDefault
typeThe type of the toggle group.ToggleGroupType-
dataThe data of the toggle group.ToggleGroupData[]-
defaultValueThe default value of the toggle group.string or string[]-
onValueChangeThe callback function that is called when the value of the toggle group changes.(value: string or string[]) => void-
cssThe css of the toggle group.PikasCSS-
sizeThe size of the toggle group.PikasSize24
paddingThe padding of the toggle group.ToggleGroupPadding"md"
borderRadiusThe border radius of the toggle group.PikasRadius"md"
borderWidthThe border width of the toggle group.number2
boxShadowThe box shadow of the toggle group.PikasShadow or "none""bottom-sm"
colorNameThe color name of the toggle group.PikasColor"primary"
colorHexThe color hex of the toggle group.string-
contentColorNameThe content color name of the toggle group.PikasColor-
contentColorHexThe content color hex of the toggle group.string-
orientationThe orientation of the toggle group.ToggleGroupOrientation"horizontal"
outlinedThe outlined of the toggle group.booleanfalse
disabledThe disabled of the toggle group.boolean-
rovingFocusThe roving focus of the toggle group.booleantrue
directionThe direction of the toggle group.ToggleGroupDirection"ltr"
loopThe loop of the toggle group.booleantrue

Contributing

This documentation can be edited on GitHub here