PetalComponents.Helpers (petal_components v3.0.1)
View SourceFor any helper functions used across multiple components. Ideally we keep this empty - components should be copy-pastable.
Summary
Functions
Generates a unique HTML ID based on the given string or iodata.
Functions
Generates a unique HTML ID based on the given string or iodata.
Parameters
- input: The input string or iodata (e.g., heading or label)
- prefix: An optional prefix for the ID (default: "c")
Examples
iex> PetalComponents.Helpers.uniq_id("My Heading")
"c-my-heading-1234"
iex> PetalComponents.Helpers.uniq_id(["My ", {:safe, "<a>Link</a>"}, " Label"], "custom")
"custom-my-link-label-5678"