Skip to content

bluzky/salad_ui

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

A collection of Live View components inspired by shadcn



Tests Module Version Hex Docs Total Download Last Updated

Demo admin

🚧 V1 is now beta release

Buy Me a Coffee at ko-fi.com

Installation

  1. Add salad_ui to your mix.exs
def deps do
  [
    {:salad_ui, "~> 1.0.0-beta.3"},
  ]
end
  1. Choose your installation method:

Method 1: Quick Setup (Using as Library)

For a quick start with minimal configuration:

mix salad.setup

This sets up SaladUI to use components directly from the library. You can start using components immediately:

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:

# 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:

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
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
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

😘 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