Installation
Add Noora to a Phoenix application: the dependency, the styles, the hooks, and the components.
-
Add the dependency
Noora is published to Hex. Add it to the dependencies in
mix.exs:defp deps do [ {:noora, "~> 0.81"} ] endElixirdefp deps do[{:noora, "~> 0.81"}]end -
Import the styles
Import the fonts and the component styles in
assets/css/app.css.noora/fonts.cssloads Inter Variable and Geist Mono from Google Fonts and rsms.me.@import "noora/fonts.css"; @import "noora/noora.css";CSS@import "noora/fonts.css";@import "noora/noora.css"; -
Register the hooks
Interactive components such as dropdowns, modals, and date pickers run on LiveView hooks. Add them to the socket in
assets/js/app.js:import Noora from "noora"; let liveSocket = new LiveSocket("/live", Socket, { hooks: { ...Noora.Hooks }, });JavaScriptimport Noora from "noora";let liveSocket = new LiveSocket("/live", Socket, {hooks: { ...Noora.Hooks },}); -
Use the components
use Nooraimports every component into a LiveView or component module.defmodule MyAppWeb.ProjectLive do use MyAppWeb, :live_view use Noora def render(assigns) do ~H""" <.button label="Create project" variant="primary" /> """ end endElixirdefmodule MyAppWeb.ProjectLive douse MyAppWeb, :live_viewuse Nooradef render(assigns) do~H"""<.button label="Create project" variant="primary" />"""endend
Self-hosted fonts
To avoid requests to third-party font hosts, serve Inter Variable and Geist Mono yourself. Declare their font faces and import
noora/noora.css
without noora/fonts.css.
@font-face {
font-family: "Inter Variable";
src: url("/fonts/InterVariable.woff2") format("woff2");
font-weight: 100 900;
font-display: swap;
font-optical-sizing: auto;
}
@font-face {
font-family: "Geist Mono";
src: url("/fonts/GeistMono.woff2") format("woff2");
font-weight: 400 700;
font-display: swap;
}
@import "noora/noora.css";