9ui Documentation
repository·main·Indexed 20 days ago
https://github.com/borabaloglu/9uiA library of copy-and-paste UI components built on top of Base UI and Tailwind CSS. 9ui provides highly customizable components—including Accordion, Alert, Autocomplete, Avatar, and Charting tools—designed for developers to integrate directly into their projects without the constraints of a traditional installed package.
What's inside 9ui
- 9ui is a collection of copy-and-paste components designed for easy customization. It is built using Base UI and Tailwind CSS, allowing developers to integrate components directly into their projects while maintaining full control over the styling and implementation.
About the Chart component
mainTheChartcomponent in 9ui is a wrapper built on top of recharts, a React component library for building charts. It provides a styled interface for various data visualizations including Area, Bar, Line, Pie, Radar, Radial Bar, and Scatter charts.Autocomplete feature variations
mainThe Autocomplete component supports several advanced patterns and configurations:
- Groupped: Organize suggestions into logical groups.
- Async: Fetch suggestions from an external API as the user types.
- Inline Autocomplete: Display suggestions within the input context.
- Fuzzy Matcher: Use fuzzy search logic to find matches that aren't exact.
- Auto Highlight: Automatically highlight the matching portion of the text in the suggestions.
- Limit Results: Restrict the number of suggestions shown to improve performance or focus.
- With Rows: Display suggestions in a row-based layout.
- Virtualized: Use virtualization to handle very large lists of suggestions efficiently.
Carousel component anatomy
mainThe Carousel component follows a specific hierarchy to function correctly:
Carousel: The main container component.CarouselContent: The wrapper for the slides that handles the scrolling logic.CarouselItem: Individual slides within the carousel.CarouselPrevious: The button to navigate to the previous item.CarouselNext: The button to navigate to the next item.
Icon libraries in 9ui
main9ui components use
lucide-reactas the default icon library. You can also use alternative libraries depending on your project needs:- Monicon: Access over 200,000 icons from various libraries.
- lucide-animated: A collection of animated icons for enhanced interaction.
9ui technical requirements and compatibility
mainFramework Support
9ui is compatible with any framework that supports React, including:
- Next.js
- Remix
- Astro
- Gatsby
Styling Requirements
Tailwind CSS is required. 9ui is built with Tailwind CSS and cannot be used without it.
Combobox variants and patterns
mainThe Combobox component supports several specialized usage patterns:
- Input inside popup: Moving the search input inside the dropdown content rather than having it as a standalone trigger.
- Multiple selection: Allowing users to select more than one item, typically rendered using
ComboboxChipsandComboboxChip. - Creatable: Enabling users to create new items that are not present in the initial list.
Understand the semantic color token system
mainThe 9ui theme system uses semantic color tokens that represent specific use cases rather than literal colors. This allows you to change the entire look of your application by swapping the underlying values of these tokens without changing your component code.
Token Categories
Base Colors: Primary surface and text colors.
background/foreground: Primary background and text.card/card-foreground: For card components.popover/popover-foreground: For popovers, dropdowns, and dialogs.
Interactive Elements: Colors for user actions.
primary/primary-foreground: Main brand color for primary actions.secondary/secondary-foreground: Less prominent actions.muted/muted-foreground: Subdued elements like secondary text.accent/accent-foreground: Highlighted or featured elements.destructive/destructive-foreground: Dangerous actions.
Status Colors: Visual feedback for states.
danger/danger-foreground/danger-border: Error states.warning/warning-foreground/warning-border: Warning messages.info/info-foreground/info-border: Informational messages.success/success-foreground/success-border: Success states.
Utility Colors: Structural colors.
border: Default border color.input: Form input borders.ring: Focus ring color.
Chart Colors: Data visualization colors.
chart-1throughchart-5: Predefined colors for charts.
Calendar selection modes
mainThe
Calendarcomponent supports several selection modes via its props:- Single Date: Select one specific date.
- Multiple Dates: Select one or more individual dates.
- Date Range: Select a start and end date to define a range.
- Disabled: You can disable specific dates to prevent selection.
Set up dark mode in Astro
mainTo implement dark mode in an Astro project, you need to prevent theme flashing by using an inline script in your main layout or page to apply the correct theme class before the page renders. This script checks
localStoragefor a saved preference or falls back to the system'sprefers-color-schemesetting.- Add an
is:inlinescript to your Astro component (e.g.,src/pages/index.astro) to manage thedocument.documentElementclasses. - Use a
MutationObserverwithin that script to automatically persist theme changes tolocalStoragewhenever theclassattribute on the<html>element changes.
<script is:inline> function getTheme() { if (typeof localStorage !== "undefined" && localStorage.getItem("theme")) { return localStorage.getItem("theme") } return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light" } const theme = getTheme() document.documentElement.classList.remove("light", "dark") document.documentElement.classList.add(theme) if (typeof localStorage !== "undefined") { const observer = new MutationObserver(() => { const isDark = document.documentElement.classList.contains("dark") localStorage.setItem("theme", isDark ? "dark" : "light") }) observer.observe(document.documentElement, { attributes: true, attributeFilter: ["class"] }) } </script>- Add an
Use the Radio Group component
mainThe Radio Group component is composed of a
RadioGroupcontainer and individualRadioGroupItemcomponents. This allows users to select exactly one option from a set of radio buttons.Import the components from your local UI directory (typically
@/components/ui/radio-group) and nestRadioGroupItemelements inside aRadioGroup.import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group" // Usage anatomy: <RadioGroup> <RadioGroupItem value="option-1" /> <RadioGroupItem value="option-2" /> </RadioGroup>Install the Pagination component
mainInstall the
@9ui/paginationcomponent using the shadcn CLI. After running the command, you will need to copy the component source code into your project's UI directory.npx shadcn@latest add @9ui/pagination