# π» DaisyUI Components
[](https://github.com/phcurado/daisy_ui_components/actions/workflows/ci.yml)
[](https://coveralls.io/github/phcurado/daisy_ui_components?branch=main)
[](https://hex.pm/packages/daisy_ui_components)
[](https://hexdocs.pm/daisy_ui_components)
[](https://hex.pm/packages/daisy_ui_components)
π [Storybook](https://daisy-ui-components-site.fly.dev/storybook/welcome)
---
<a href='https://ko-fi.com/R5R11AIF9P' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://storage.ko-fi.com/cdn/kofi6.png?v=6' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a>
This project brings [DaisyUI](https://daisyui.com/) components into your [Phoenix](https://www.phoenixframework.org) project.

## π¦ Installation
<!-- MDOC -->
Reference this repository on your `mix.exs` file to start using.
```elixir
def deps do
[
{:daisy_ui_components, "~> 0.7"}
]
end
```
Add through `npm` the daisy UI package inside your phoenix application:
```bash
cd assets
npm i -D daisyui@latest
```
On `tailwind.config.js` include Live DaisyUI Components under the content list and reference under plugins
```javascript
module.exports = {
content: [
//...
"../deps/daisy_ui_components/**/*.*ex" // <- reference DaisyUIComponents as content path
],
//...
plugins: [
//...
// comment the tailwind form to not conflict with DaisyUI
// require("@tailwindcss/forms"),
require("daisyui") <- // add daisyUI plugin
//...
]
}
```
Add error translation function to your app's config.exs file. This function is used to translate ecto changeset errors
```elixir
config :daisy_ui_components, translate_function: &MyAppWeb.CoreComponents.translate_error/1
```
And now this library is ready. To have the components available under liveview, import the components on the web folder
```elixir
defp html_helpers do
quote do
# Translation
use Gettext, backend: MyAppWeb.Gettext
# HTML escaping functionality
import Phoenix.HTML
# Import DaisyUI components into your project
use DaisyUIComponents
# Comment your own CoreComponents to not conflict with the defaults of this library.
# import YourProjectWeb.CoreComponents
# Importing CoreComponents from your project is no longer necessary since
# DaisyUIComponents.CoreComponents offers a drop in replacement
# If you still want to use your own core components, remember to delete the default components generated from phoenix in this file
# ...
end
end
```
Finally, in order to not conflict with some of the DaisyUI default styles, remove the `bg-white` class in your `root.html.heex` file.
```heex
## Change from this
<body class="bg-white">
## to this
<body>
```
## β Core Components
This library aims to integrate seamlessly with Phoenix generators. For this reason you don't need the components inside the `CoreComponents` after adding `use DaisyUIComponents` into your web file.
All the components should be compatible, styled with DaisyUI.
If you encounter any compatibility issues, feel free to open an `issue` or submit a `pull request`, and I'll take a look.
## π€ Liveview 1.0
This project is fully compatible with the Liveview 1.0 π₯. If you are using a previous Liveview version, check the [migration guide](https://github.com/phoenixframework/phoenix_live_view/blob/v1.0/CHANGELOG.md).
## π¦ NPM setup
Since DaisyUI requires `npm` to install, it's also necessary to configure in your project the asset pipeline to use the npm commands.
In your `mix.exs` file, add the npm command in your assets setup:
```diff
"assets.setup": [
"tailwind.install --if-missing",
- "esbuild.install --if-missing"
+ "esbuild.install --if-missing",
+ "cmd npm install --prefix assets"
]
```
and if you are deploying the application with `Docker`, run the npm scripts there too:
```diff
# install build dependencies
-RUN apt-get update -y && apt-get install -y build-essential git \
+RUN apt-get update -y && apt-get install -y build-essential git npm \
&& apt-get clean && rm -f /var/lib/apt/lists/*_*
# ...
RUN mix deps.compile
# build assets
+COPY assets/package.json assets/package-lock.json ./assets/
+RUN npm --prefix ./assets ci --progress=false --no-audit --loglevel=error
```
## β‘οΈ Components
List of available components.
### Actions
| Component | Status | Storybook |
| -------------------------------------------------------------------- | ------ | --------- |
| [Button](https://daisyui.com/components/button) | β
| β
|
| [Dropdown](https://daisyui.com/components/dropdown) | β
| β
|
| [Modal](https://daisyui.com/components/modal) | β
| β
|
| [Swap](https://daisyui.com/components/swap) | β
| β
|
| [Theme Controller](https://daisyui.com/components/theme-controller/) | β | β |
### Data Display
| Component | Status | Storybook |
| ----------------------------------------------------- | ------ | --------- |
| [Accordion](https://daisyui.com/components/accordion) | β | β |
| [Avatar](https://daisyui.com/components/avatar) | β
| β
|
| [Badge](https://daisyui.com/components/badge) | β
| β
|
| [Card](https://daisyui.com/components/card) | β
| β
|
| [Carousel](https://daisyui.com/components/carousel) | β | β |
| [Chat bubble](https://daisyui.com/components/chat) | β | β |
| [Collapse](https://daisyui.com/components/collapse) | β | β |
| [Countdown](https://daisyui.com/components/countdown) | β | β |
| [Diff](https://daisyui.com/components/diff/) | β | β |
| [Kbd](https://daisyui.com/components/kbd) | β | β |
| [Stat](https://daisyui.com/components/stat) | β
| β
|
| [Table](https://daisyui.com/components/table) | β
| β
|
| [Timeline](https://daisyui.com/components/timeline/) | β | β |
### Navigation
| Component | Status | Storybook |
| ---------------------------------------------------------------------- | ------ | --------- |
| [Breadcrumbs](https://daisyui.com/components/breadcrumbs) | β
| β
|
| [Bottom navigation](https://daisyui.com/components/bottom-navigation/) | β | β |
| [Link](https://daisyui.com/components/link) | β | β |
| [Menu](https://daisyui.com/components/menu) | β
| β
|
| [Navbar](https://daisyui.com/components/navbar) | β
| β
|
| [Pagination](https://daisyui.com/components/pagination) | β
| β
|
| [Steps](https://daisyui.com/components/steps) | β | β |
| [Tabs](https://daisyui.com/components/tab) | β | β |
### Feedback
| Component | Status | Storybook |
| ----------------------------------------------------------------- | ------ | --------- |
| [Alert](https://daisyui.com/components/alert) | β
| β
|
| [Loading](https://daisyui.com/components/loading/) | β
| β
|
| [Progress](https://daisyui.com/components/progress) | β | β |
| [Radial progress](https://daisyui.com/components/radial-progress) | β | β |
| [Skeleton](https://daisyui.com/components/skeleton/) | β | β |
| [Toast](https://daisyui.com/components/toast) | β | β |
| [Tooltip](https://daisyui.com/components/tooltip) | β
| β
|
### Data Input
| Component | Status | Storybook |
| ------------------------------------------------------- | ------ | --------- |
| [Checkbox](https://daisyui.com/components/checkbox) | β
| β
|
| [File input](https://daisyui.com/components/file-input) | β | β |
| [Radio](https://daisyui.com/components/radio) | β
| β
|
| [Range](https://daisyui.com/components/range) | β
| β
|
| [Rating](https://daisyui.com/components/rating) | β | β |
| [Select](https://daisyui.com/components/select) | β
| β
|
| [Text Input](https://daisyui.com/components/input) | β
| β
|
| [Textarea](https://daisyui.com/components/textarea) | β
| β
|
| [Toggle](https://daisyui.com/components/toggle) | β
| β
|
### Layout
| Component | Status | Storybook |
| ----------------------------------------------------- | ------ | --------- |
| [Artboard](https://daisyui.com/components/artboard) | β | β |
| [Divider](https://daisyui.com/components/divider) | β | β |
| [Drawer](https://daisyui.com/components/drawer) | β
| β
|
| [Footer](https://daisyui.com/components/footer) | β | β |
| [Hero](https://daisyui.com/components/hero) | β
| β
|
| [Indicator](https://daisyui.com/components/indicator) | β
| β
|
| [Join](https://daisyui.com/components/join) | β
| β
|
| [Mask](https://daisyui.com/components/mask) | β | β |
| [Stack](https://daisyui.com/components/stack) | β | β |
### Mockup
| Component | Status | Storybook |
| --------------------------------------------------------- | ------ | --------- |
| [Browser](https://daisyui.com/components/mockup-browser/) | β | β |
| [Code](https://daisyui.com/components/mockup-code) | β | β |
| [Phone](https://daisyui.com/components/mockup-phone) | β | β |
| [Window](https://daisyui.com/components/mockup-window) | β | β |
### Phoenix Core Components
| Component | Status | Storybook |
| ----------- | ------ | --------- |
| Flash | β
| β
|
| Header | β
| β
|
| List | β
| β
|
| Simple Form | β
| β
|
| Input | β
| β
|
| Table | β
| β
|
## πΊοΈ Roadmap
- Implement all components
- Document all components in Storybook
- Create `mix` script to enable users to import the components of this library into their projects, sharing the same project namespace.