Current section

Files

Jump to
salad_ui README.md
Raw

README.md

<p align="center">
<a href="https://salad-storybook.fly.dev/" alt="SaladUI Logo">
<img src="https://github.com/bluzky/salad_ui/blob/main/docs/images/SaladUI_logo.png?raw=true" height="120"/></a>
</p>
<h4 align="center">
A collection of Live View components inspired by shadcn
</h4>
<div align="center">
<a href="https://salad-storybook.fly.dev/">Demo</a> |
<a href="https://hexdocs.pm/salad_ui/readme.html">Documentation</a> |
<a href="https://ko-fi.com/bluzky">Support project</a>
</div>
<br></br>
<div align="center">
<img src="https://github.com/bluzky/salad_ui/actions/workflows/tests.yml/badge.svg" alt="Tests">
<a href="https://hex.pm/packages/salad_ui"><img src="https://img.shields.io/hexpm/v/salad_ui.svg" alt="Module Version"></a>
<a href="https://hexdocs.pm/salad_ui/"><img src="https://img.shields.io/badge/hex-docs-lightgreen.svg" alt="Hex Docs"></a>
<a href="https://hex.pm/packages/salad_ui"><img src="https://img.shields.io/hexpm/dt/salad_ui.svg" alt="Total Download"></a>
<a href="https://github.com/bluzky/salad_ui/commits/main"><img src="https://img.shields.io/github/last-commit/bluzky/salad_ui.svg" alt="Last Updated"></a>
</div>
![Demo admin](./docs/images/demo.gif)
## 🚧 V1 is now beta release
## [Demo storybook v1](https://salad-storybook.fly.dev/)
<a href='https://ko-fi.com/F1F1CEZ91' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://storage.ko-fi.com/cdn/kofi2.png?v=6' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
## Installation
1. Add `salad_ui` to your `mix.exs`
```elixir
def deps do
[
{:salad_ui, "~> 1.0.0-beta.2"},
]
end
```
2. Choose your installation method:
### Method 1: Quick Setup (Using as Library)
For a quick start with minimal configuration:
```bash
mix salad.setup
```
This sets up SaladUI to use components directly from the library. You can start using components immediately:
```elixir
defmodule MyAppWeb.PageLive do
use MyAppWeb, :live_view
import SaladUI.Button
import SaladUI.Dialog
def render(_) do
~H"""
<.button>Click me</.button>
<.dialog id="my-dialog">
<.dialog_content>
<p>Hello world!</p>
</.dialog_content>
</.dialog>
"""
end
end
```
### Method 2: Local Installation (Customizable)
For full customization with local component files:
```bash
# Default installation
mix salad.install
# With custom prefix and color scheme
mix salad.install --prefix MyUI --color-scheme slate
```
This copies all component files to your project under `lib/my_app_web/components/ui/` where you can customize them:
```elixir
defmodule MyAppWeb.PageLive do
use MyAppWeb, :live_view
import MyAppWeb.Components.UI.Button
import MyAppWeb.Components.UI.Dialog
def render(_) do
~H"""
<.button>Click me</.button>
<.dialog id="my-dialog">
<.dialog_content>
<p>Hello world!</p>
</.dialog_content>
</.dialog>
"""
end
end
```
## What Each Method Does
### `mix salad.setup`
- βœ… Sets up Tailwind CSS and color schemes
- βœ… Configures JavaScript hooks and components
- βœ… Ready to use immediately
- ❌ Components cannot be customized
- ❌ Uses external package dependencies
### `mix salad.install`
- βœ… Sets up Tailwind CSS and color schemes
- βœ… Copies all component source code locally
- βœ… Copies all JavaScript files locally
- βœ… Full customization possible
- βœ… No external runtime dependencies
- βœ… Custom module prefixes
## More configuration
1. Custom error translate function
```elixir
config :salad_ui, :error_translator_function, {MyAppWeb.CoreComponents, :translate_error}
```
## πŸ› οΈ Development
Here is how to start develop SaladUI on local machine.
1. Clone this repo
2. Go into storybook folder
3. Start storybook
```
cd storybook
mix phx.server
```
## Unit Testing
All v1 component are not covered by UnitTest. Currently I'm working on an important project so I don't have much time for this. If you're interested in this project, please help to add Unit Test if possible. πŸ™
## List of components
| Component | v0 | v1 |
|----------------|------|------|
| Accordion | βœ… | βœ… |
| Alert | βœ… | βœ… |
| Alert Dialog | βœ… | βœ… |
| Avatar | βœ… | βœ… |
| Badge | βœ… | βœ… |
| Breadcrumb | βœ… | βœ… |
| Button | βœ… | βœ… |
| Card | βœ… | βœ… |
| Carousel | ❌ | |
| Checkbox | βœ… | βœ… |
| Collapsible | βœ… | βœ… |
| Combobox | ❌ | |
| Command | ❌ | βœ… [@ilyabayel](https://github.com/ilyabayel) |
| Context Menu | ❌ | |
| Dialog | βœ… | βœ… |
| Drawer | ❌ | |
| Dropdown Menu | βœ… | βœ… |
| Form | βœ… | βœ… |
| Hover Card | βœ… | βœ… |
| Input | βœ… | βœ… |
| Input OTP | ❌ | |
| Label | βœ… | βœ… |
| Pagination | βœ… | βœ… |
| Popover | βœ… | βœ… |
| Progress | βœ… | βœ… |
| Radio Group | βœ… | βœ… |
| Scroll Area | βœ… | βœ… |
| Select | βœ… | βœ… |
| Separator | βœ… | βœ… |
| Sheet | βœ… | βœ… |
| Skeleton | βœ… | βœ… |
| Slider | βœ… | βœ… |
| Switch | βœ… | βœ… |
| Table | βœ… | βœ… |
| Tabs | βœ… | βœ… |
| Textarea | βœ… | βœ… |
| Tooltip | βœ… | βœ… |
## 🌟 Contributors
<p align="center">
<a href="https://github.com/bluzky/salad_ui/graphs/contributors">
<img src="https://contrib.rocks/image?repo=bluzky/salad_ui&max=300&columns=14" width="600"/></a>
</p>
## 😘 Credits
This project could not be available without these awesome works:
- `tailwind css` an awesome css utility project
- `turboprop` I borrow code from here for merging tailwinds classes
- `shadcn/ui` which this project is inspired from
- `Phoenix Framework` of course