answerui
Use the @answerdotai/answerui npm package for the browser foundation: a stylesheet keyed on semantic HTML attributes and CSS custom properties, optional fonts, and vanilla JavaScript modules. Use the answerui-py Python package to add FastHTML constructors and a registry for app-specific CSS and browser behavior on top of those same assets.
Python constructors emit marked HTML, such as <section card> from Card() and <button btn> from Btn(). AnswerUI does not restyle unmarked form elements. Frontend frameworks such as Svelte can emit the same markup and import the JavaScript modules directly without Python. The notebooks cover the generated OKLCH palette, typography and spacing scales, parent-driven layouts, UI components, and the Python registry.
Read answerui.skill with doc(answerui.skill) for an LLM guide to building FastHTML pages, inspecting and customising registered components, and previewing results in a persistent Python kernel.
Install
For a JavaScript app:
npm install @answerdotai/answerui
Import the stylesheet once:
import '@answerdotai/answerui/styles.css';
import {mountPopover} from '@answerdotai/answerui/floating.js';
@answerdotai/answerui/styles.css works without JavaScript, including native dialogs, disclosures, and CSS tooltips. Import individual browser modules only for components that require JavaScript: @answerdotai/answerui/floating.js for popovers, @answerdotai/answerui/fit.js for responsive navbars, @answerdotai/answerui/interactions.js for tabs, toolbars, and hover cards, and @answerdotai/answerui/copy.js for clipboard actions. Load @answerdotai/answerui/fonts.css to use the bundled IBM Plex font faces.
For server-rendered or static HTML (with HTMX 4 for swap-driven behaviors such as dialog auto-open), import '@answerdotai/answerui/browser.js' mounts those behaviors automatically on marked elements and observes later DOM insertions. In Svelte or another component framework, import the individual modules inside your component lifecycle instead of loading @answerdotai/answerui/browser.js.
For FastHTML (requires python-fasthtml>=0.15 / HTMX 4):
pip install answerui-py
If you serve the browser assets directly from Python, from answerui import assets returns the packaged Path to the assets directory.
Use from Python
reg.hdrs() returns the shared foundation stylesheet, browser scripts, and registered app rules. reg.ftrs() returns the fastlucide icon sprite sheet. Because FastHTML evaluates both on every response, newly registered rules take effect on the next request without a restart:
from fasthtml.common import *
from answerui.all import *
app = FastHTML(hdrs=reg.hdrs(), ftrs=reg.ftrs())
rt = app.route
To serve cached assets instead of inlining them on every page, create the app without reg.hdrs() or reg.ftrs(), then call reg.serve(app). That call registers the headers, icon sprite sheet, and content-hashed asset routes while preserving relative imports between the browser JavaScript modules.
served_app = FastHTML()
reg.serve(served_app);
Each Python constructor renders standard HTML with a semantic attribute. Below, Card renders <section card> and Stack wraps the children in <div stack> to space them vertically:
page = Card(Stack(H2('Profile'), Field('Name', Input(name='name')), Cluster(Btn('Save'), Btn('Cancel', variant='secondary'))))
demo(page)
<section card>
<div stack>
<h2>Profile</h2>
<div field>
<label for="_6_wOUck0TCmC42cGHKE3Hw">Name</label> <div field-control>
<input input name="name" id="_6_wOUck0TCmC42cGHKE3Hw">
</div>
</div>
<div cluster>
<button type="button" btn btn-variant="primary">Save</button><button type="button" btn btn-variant="secondary">Cancel</button> </div>
</div>
</section>
demo(page) renders the Python markup with the same stylesheet and browser scripts used by JavaScript applications.
Customise
Register standard CSS at the scope you want to change: :root custom properties via reg.rule for the whole app, a scoped selector for one region, or a component rule via Btn.rule. Because registered rules are placed in the app cascade layer after every framework layer except utilities, they override AnswerUI defaults without modifying the package:
reg.rule(':root { --hue: 150; --radius: 0; }', 'theme')
Btn.rule('caps', 'text-transform: uppercase;')
Btn.caps [app] [btn]
Call .variant() on a component to declare a named style modifier. The component constructor then accepts that variant name as a keyword argument. Declared variants also appear in the component’s documentation:
Btn.variant('cta', '--ui-pad-block: var(--space); --ui-pad-inline: var(--space2); font-size: var(--text1);', doc='The landing page call to action.')
Btn.cta [app] :is([btn])[cta]: The landing page call to action.
Declaring a variant registers an app-layer rule for that attribute on the component element without modifying the default styles in styles.css.
demo(Btn('Request access', cta=True))
<button type="button" btn btn-variant="primary" cta>Request access</button>
Btn
Btn(*c, variant='primary', size=None, href=None, type='button', icon=False, **attrs)
A raised action, latched by aria-pressed and sunken while busy or expanded
Root selector: [btn].
Declared variants:
cta: The landing page call to action.
Rules:
base(app)caps(app)
Previews in notebooks
demo(page) returns a Preview with two MIME representations: an HTML iframe containing the full stylesheet and browser scripts, and a Markdown block of the HTML markup. Because each iframe embeds the entire stylesheet, committing them would bloat notebooks and churn diffs on every stylesheet edit. Preview._repr_mimebundle_ sets nbdev’s strip metadata flag on the HTML output. When you run nbdev-clean, it strips the iframe and keeps the Markdown markup in git. In a fresh clone, run the notebook cells to display the iframes again.
For the docs, set exec_all in pyproject.toml:
[tool.nbdev]
exec_all = true
nbdev-docs then executes every notebook and renders each iframe from the current code.
With an LLM
answerui.skill is a pyskill whose module docstring documents how to use AnswerUI in a Python kernel. Run list_pyskills() to discover it, doc(answerui.skill) to read the guide, and doc(Btn) to inspect a component’s signature, declared variants, and CSS rules.
Metadata
Release files for answerui-py 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| answerui_py-0.0.7.tar.gz | 903.3 kB | With provenance | Details for answerui_py-0.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| answerui_py-0.0.7-py3-none-any.whl | Python 3 | none | any | Details for answerui_py-0.0.7-py3-none-any.whl |
Total release size: 1.1 MB
Release files / answerui_py-0.0.7.tar.gz
| Download URL | answerui_py-0.0.7.tar.gz |
|---|---|
| Size | 903.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd1db9c508ba573620d9e05410f71e26ff59b9f268be0252d971268b1738457c
|
|
BLAKE2b-256 checksum How to use checksums |
23c25f6ec288135228ed1f4aff0479d24ffbfd583e2cdbf124168ec29b0bd55c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / answerui_py-0.0.7-py3-none-any.whl
| Download URL | answerui_py-0.0.7-py3-none-any.whl |
|---|---|
| Size | 173.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6d5a6ac793bb1c6cf1a13c2bdec7a9ae3736d9ad4a59bdfe97ce0491e08414aa
|
|
BLAKE2b-256 checksum How to use checksums |
d9b64f6dd8754b01f2b106e5c596e24baaaf3f0b9e972f18d6092b90dadbd219
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logSecurity for answerui-py 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for answerui_py-0.0.7.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.