Supabase UI

repository·master·Indexed 23 days ago

https://github.com/supabase/ui

A UI component library for Supabase, version 0.1.3, featuring a suite of React components including Accordion, Alert, Auth, Avatar, Badge, Button, Card, Checkbox, and ContextMenu. The library includes specialized authentication interfaces with social provider support and is developed using Storybook.

Tokens
18.8K
Snippets
6
Records
350
Agent score
82%

What's inside @supabase/ui

  1. What is Storybook and how to use it

    master

    Storybook is a tool used to build UI components in isolation from your application's business logic, data, and context. This isolation allows you to develop hard-to-reach component states easily.

    Key concepts:

    • Stories: Saved UI states that you can revisit during development, testing, or QA.
    • Component-driven development: A recommended process of building UIs starting from atomic components and progressing toward full pages.

    To learn how to implement specific component patterns, you can examine the example stories located in the src/storybook-examples directory.

  2. Style rich-text content with the `prose` class

    master

    When using Tailwind CSS, default browser styling is removed from elements like h1, p, and ul. To style blocks of vanilla HTML content (such as content from a CMS or a Markdown file) without disabling Tailwind's base styles, use the @tailwindcss/typography plugin.

    Applying the prose class to a container element will automatically apply beautiful, well-formatted typography to all nested HTML elements within that container.

    <article class="prose">
      <h1>Garlic bread with cheese: What the science tells us</h1>
      <p>
        For years parents have espoused the health benefits of eating garlic bread with cheese to their
        children...
      </p>
    </article>
  3. Run Storybook locally

    master

    Supabase UI uses Storybook to develop and organize components. You can view components locally in the Storybook docs explorer. Ensure you are in the supabase-ui directory before running the commands.

    Storybook runs by default on http://localhost:6006/.

    cd supabase-ui
    npm install
    npm run storybook
  4. Available components in @supabase/ui

    master

    The @supabase/ui library provides a comprehensive set of React components categorized by their functional role. You can import these components directly from the main entrypoint.

    General

    • Button
    • Typography
    • Icon
    • Image

    Displays

    • Card
    • Badge
    • Tabs
    • Alert
    • Accordion
    • Menu

    Overlays

    • Modal
    • SidePanel
    • Dropdown
    • ContextMenu
    • Popover

    Utilities

    • Space
    • Loading
    • Divider

    Data Entry

    • Select
    • Listbox
    • Checkbox
    • Input
    • InputNumber
    • Radio
    • Toggle
    • Upload

    Auth

    • Auth
  5. Resolve multiple React versions during local testing

    master

    A common issue when testing the library locally is having multiple versions of React running simultaneously. To resolve this, you can link the React instance from your target application into the supabase-ui library so that both use the same single copy of React.

    Follow these steps:

    1. In your target application's directory, run: npm link inside /your-app/node_modules/react to create a global link for that specific React version.
    2. In the supabase-ui directory, run: npm link react to make the library use the application's React copy.
    3. In your target application's directory, run: npm link @supabase/ui to link the library into your app.
  6. Available Icon components

    master

    The following icon components are exported from the library. They are mapped to react-feather icons:

    • Activity
    • Airplay
    • AlertCircle
    • AlertOctagon
    • AlertTriangle
    • AlignCenter
    • AlignJustify
    • AlignLeft
    • AlignRight
    • Anchor
    • Aperture
    • Archive
    • ArrowDownCircle
    • ArrowDownLeft
    • ArrowDownRight
    • ArrowDown
    • ArrowLeftCircle
    • ArrowLeft
    • ArrowRightCircle
    • ArrowRight
    • ArrowUpCircle
    • ArrowUpLeft
    • ArrowUpRight
    • ArrowUp
    • AtSign
    • Award
    • BarChart2
    • BarChart
    • BatteryCharging
    • Battery
    • BellOff
    • Bell
    • Bluetooth
    • Bold
    • BookOpen
    • Book
    • Bookmark
    • Box
    • Briefcase
    • Calendar
    • CameraOff
    • Camera
    • Cast
    • CheckCircle
    • CheckSquare
    • Check
    • ChevronDown
    • ChevronLeft
    • ChevronRight
    • ChevronUp
    • ChevronsDown
    • ChevronsLeft
    • ChevronsRight
    • ChevronsUp
    • Chrome
    • Circle
    • Clipboard
    • Clock
    • CloudDrizzle
    • CloudLightning
    • CloudOff
    • CloudRain
    • CloudSnow
    • Cloud
    • Code
    • Codepen
    • Codesandbox
    • Coffee
    • Columns
    • Command
    • Compass
    • Copy
    • CornerDownLeft
    • CornerDownRight
    • CornerLeftDown
    • CornerLeftUp
    • CornerRightDown
    • CornerRightUp
    • CornerUpRight
    • Cpu
    • CreditCard
    • Crop
    • Crosshair
    • Database
    • Delete
    • Disc
    • DivideCircle
    • DivideSquare
    • Divide
    • DollarSign
    • DownloadCloud
    • Download
    • Dribbble
    • Droplet
    • Edit2
    • Edit3
    • Edit
    • ExternalLink
    • EyeOff
    • Eye
    • Facebook
    • FastForward
    • Feather
    • Figma
    • FileMinus
    • FilePlus
    • FileText
    • File
    • Film
    • Filter
    • Flag
    • FolderMinus
    • FolderPlus
    • Folder
    • Framer
    • Frown
    • Gift
    • GitBranch
    • GitCommit
    • GitMerge
    • GitPullRequest
    • GitHub
    • Gitlab
    • Globe
    • Grid
    • HardDrive
    • Hash
    • Headphones
    • Heart
    • HelpCircle
    • Hexagon
    • Home
    • Image
    • Inbox
    • Info
    • Instagram
    • Italic
    • Key
    • Layers
    • Layout
    • LifeBuoy
    • Link2
    • Link
    • Linkedin
    • List
    • Loader
    • Lock
    • LogIn
    • LogOut
    • Mail
    • MapPin
    • Map
    • Maximize2
    • Maximize
    • Meh
    • Menu
    • MessageCircle
    • MessageSquare
    • MicOff
    • Mic
    • Minimize2
    • Minimize
    • MinusCircle
    • MinusSquare
    • Minus
    • Monitor
    • Moon
    • MoreHorizontal
    • MoreVertical
    • MousePointer
    • Move
    • Music
    • Navigation2
    • Navigation
    • Octagon
    • Package
    • Paperclip
    • PauseCircle
    • Pause
    • PenTool
    • Percent
    • PhoneCall
    • PhoneForwarded
    • PhoneIncoming
    • PhoneMissed
    • PhoneOff
    • PhoneOutgoing
    • Phone
    • PieChart
    • PlayCircle
    • Play
    • PlusCircle
    • PlusSquare
    • Plus
    • Pocket
    • Power
    • Printer
    • Radio
    • RefreshCcw
    • RefreshCw
    • Repeat
    • Rewind
    • RotateCcw
    • RotateCw
    • Rss
    • Save
    • Scissors
    • Search
    • Send
    • Server
    • Settings
    • Share2
    • Share
    • ShieldOff
    • Shield
    • ShoppingBag
    • ShoppingCart
    • Shuffle
    • Sidebar
    • SkipBack
    • SkipForward
    • Slack
    • Slash
    • Sliders
    • Smartphone
    • Smile
    • Speaker
    • Square
    • Star
    • StopCircle
    • Sun
    • Sunrise
    • Sunset
    • Tablet
    • Tag
    • Target
    • Terminal
    • Thermometer
    • ThumbsDown
    • ThumbsUp
    • ToggleLeft
    • ToggleRight
    • Tool
    • Trash2
    • Trash
    • Trello
    • TrendingDown
    • TrendingUp
    • Triangle
    • Truck
    • Tv
    • Twitch
    • Twitter
    • Type
    • Umbrella
    • Underline
    • Unlock
    • UploadCloud
    • Upload
    • UserCheck
    • UserMinus
    • UserPlus
    • UserX
    • User
    • Users
    • VideoOff
    • Video
    • Voicemail
    • Volume1
    • Volume2
    • VolumeX
    • Volume
    • Watch
    • WifiOff
    • Wifi
    • Wind
    • XCircle
    • XOctagon
    • XSquare
    • X
    • Youtube
    • ZapOff
    • Zap
    • ZoomIn
    • ZoomOut
  7. Implement Checkbox and Radio controls in ContextMenu

    master

    You can include interactive selection controls like checkboxes and radio buttons directly within a ContextMenu overlay.

    Checkbox

    Use ContextMenu.Checkbox with checked and onChange props to manage state.

    Radio Group

    Use ContextMenu.RadioGroup with value and onChange props to manage a single selection among multiple ContextMenu.Radio items.

    // Checkbox Example
    const [checked, setChecked] = useState(false)
    
    <ContextMenu
      overlay={[
        <ContextMenu.Item>Settings</ContextMenu.Item>,
        <Divider light />,
        <ContextMenu.Checkbox checked={checked} onChange={setChecked}>
          Show subtitles
        </ContextMenu.Checkbox>,
      ]}
    >
      <div id="trigger">Right click me</div>
    </ContextMenu>
    
    // Radio Group Example
    const [value, setValue] = useState('red')
    
    <ContextMenu
      overlay={[
        <ContextMenu.RadioGroup value={value} onChange={setValue}>
          <ContextMenu.Radio value={'red'}>Red</ContextMenu.Radio>
          <ContextMenu.Radio value={'blue'}>Blue</ContextMenu.Radio>
          <ContextMenu.Radio value={'green'}>Green</ContextMenu.Radio>
        </ContextMenu.RadioGroup>,
      ]}
    >
      <div id="trigger">Right click me</div>
    </ContextMenu>
  8. Use Icon components and customize their props

    master

    The @supabase/ui library provides a collection of icon components based on react-feather. Each icon is a React component that accepts standard SVG attributes along with specific color and size props for easy styling.

    IconProps

    When using an icon, you can pass the following props:

    • color (string): The color of the icon.
    • size (string | number): The size of the icon.
    • SVGAttributes<SVGElement>: Any standard SVG attributes (e.g., className, style, onClick).