View Source Get Started
This guide steps through the installation process for Pyro.
installation
Installation
The installation process is currently pretty involved, and may be omitting some required steps. This will improve over time, pinky-promise!
steps
Steps
These steps assume you are adding Pyro to an existing Phoenix LiveView app as generated from the v1.7.2+ phx.new.
Add
:pyroto your dependencies:def deps do [ {:pyro, "~> 0.1.1"}, {:ash_phoenix, "~> 1.2"}, # <-- Optional: Ash integration {:ash, "~> 2.8"}, # <-- Optional: Ash integration ] endAdd the following to your
config.exs:config :pyro, :overrides, [Pyro.Overrides.Default] config :pyro, :css_file, Path.join(File.cwd!(), "assets/css/pyro.css")Update your
tailwind.config.js, and add the noted lines:let plugin = require('tailwindcss/plugin') module.exports = { darkMode: 'class', // <-- Dark theme support content: [ // ... '../deps/pyro/lib/pyro/**/*.*ex', // <-- Ensure Pyro components are included ], // ... plugins: [ // In addition to the normal `phx` variants, add the following: plugin(({ addVariant }) => addVariant('aria-selected', '&[aria-selected]'), ), plugin(({ addVariant }) => addVariant('aria-checked', '&[aria-checked]'), ), ], }Add
pyroCSS imports toassets/css/app.css:@import 'tailwindcss/base'; @import 'tailwindcss/components'; @import 'tailwindcss/utilities'; @import './pyro.css';Add the following lines to
assets/js/app.js:import { hooks, getTimezone } from 'pyro' // ... let liveSocket = new LiveSocket('/live', Socket, { params: { _csrf_token: csrfToken, timezone: getTimezone() }, hooks: { ...hooks }, })Update
mix.exs, adding the:pyrocompiler to the list of compilers:def project do [ # ... compilers: Mix.compilers() ++ [:pyro] ] endEdit your
my_app_web.exfile, replacing:Phoenix.ComponentwithPyro.ComponentPhoenix.LiveComponentwithPyro.LiveComponentPhoenix.LiveViewwithPyro.LiveView
Note: Only replace those top-level modules, do not replace submodules, e.g.
Phoenix.LiveView.Router.(Optional) Add the generated files to your
.gitignoreif you don't want them tracked:/assets/css/pyro.css(Optional) Import the Pyro components into your
my_app_web.exhelpers to make the available in your views/components:defp html_helpers do quote do # Import all Pyro components use Pyro.Components # Don't import CoreComponents since Pyro replaces it and will conflict # import MyAppWeb.CoreComponents # ...Note:
Tailsmay occasionally complain about thecolors_filebeing different in runtime than compile time. You simply need to runmix deps.compile tails --forceto clear it up. If you are using theTailshelper functions for custom colors, you will also need to force a recompile if those change. If you are extending the default color theme, you will need to configure the colors.