Toggle

Description

The Toggle component is a customizable button that maintains a pressed state. It allows users to toggle between two states and provides optional controlled and uncontrolled behavior.

Usage


import { Toggle } from "mogora-ui";
import { EllipsisVertical  } from "lucide-react";

export default function ToggleDemo() {
  return (
    <Toggle className="size-10">
      <EllipsisVertical size={30} />
    </Toggle>
  )
}

API Reference

Toggle

A button component that toggles between pressed and unpressed states.

PropTypeDescription
childrenReactNodeContent to be displayed inside the toggle button.
pressedbooleanControlled state of the toggle button.
defaultPressedbooleanInitial state of the toggle button in uncontrolled mode.
onPressedChange(open: boolean) => voidCallback function triggered when the pressed state changes.
classNamestringAdditional CSS classes for styling the button.