FontProvider
Headless font loading with bundled presets, custom/resource URLs and separate body and heading families.
Live TypeScript example
Try the component here, then use the source below in your application.
- JavaScript
- 4.4 KiB
- Component CSS
- 0.3 KiB
- Shared theme CSS
- 3.8 KiBonce per application
How sizes are measured
The JavaScript figure includes this component’s required helpers. CSS includes its styling dependencies. Each entry is bundled separately for ES2022, minified, then compressed with gzip level 9. Your bundler may share helpers across components. Images, fonts, examples and application code are excluded.
Before compression: JavaScript 25.0 KiB; component CSS 0.4 KiB. These figures describe browser assets, not the complete package download.
View all component measurements →The provider has no visible UI. This preview applies separate body and heading fonts to a container; fallback text remains readable while fonts load.
import '@blukavantui/web/theme.css'
import {createFontProvider} from '@blukavantui/web/font-provider';
import '@blukavantui/web/font-provider.css';
export function mount(host:HTMLElement){
const content=document.createElement('section');
const heading=document.createElement('h3');heading.textContent='Northstar operations';
const body=document.createElement('p');body.textContent='Body and heading fonts are configured independently. Content stays readable while fonts load.';
content.append(heading,body);
const status=document.createElement('p');status.setAttribute('role','status');host.append(status);
// Copy @blukavantui/web/dist/fonts to your public/fonts directory.
// This starter's Vite configuration performs that copy at build time.
const provider=createFontProvider(host,{
Scope:'Container',Content:content,BodyFont:'Inter',HeadingFont:'Lora',
PresetBaseUrl:import.meta.env.BASE_URL+'fonts/',
// For a custom file, use BodyFont:'Custom', BodyFontFamily:'Brand Sans',
// BodyFontUrl:'/fonts/brand-sans.woff2', BodyFontWeight:'100 900'.
// FontFaces adds separate italic faces or Unicode subsets.
},{Loaded:(body,heading)=>{status.textContent=body+' body / '+heading+' headings loaded.';},Error:message=>{status.textContent=message;}});
return {destroy(){provider.destroy();status.remove();}};
}
const instance = mount(document.getElementById('example')!)
// When this page or framework component is removed:
// instance.destroy()
Install the library and add the host element
npm install https://blukavantui.blutekmedia.com/downloads/blukavantui-web-0.9.0.tgz<div id="example"></div>This example uses the downloadable @blukavantui/web package. Your application handles persistence and authentication through its typed callbacks. The starter ZIP includes this same example.
createFontProvider
Headless font loading. Use Scope Container with Content or TargetId, or Page for document-wide tokens. Set BodyFont and HeadingFont separately. Copy the package dist/fonts directory to your public assets and set PresetBaseUrl when using a bundler. Presets include Latin and Latin Extended coverage and their OFL licences; custom FontFaces can add other scripts, weights and italics. Custom URLs accept same-origin files or CORS-enabled HTTP(S) font files; OutSystems accepts Resource URLs through the same inputs. FontProvider restores owned styles on destroy. Portaled content outside a container needs the page scope or its own provider.
import { createFontProvider } from '@blukavantui/web/font-provider';
import '@blukavantui/web/font-provider.css';Load @blukavantui/web/theme.css once in your app shell.createFontProvider(host: HTMLElement, options?: FontProviderOptions, events?: FontProviderEvents)Reference for @blukavantui/web 0.9.0. Required and optional follow the shipped TypeScript declarations; optional does not imply a particular default. Pass typed arrays and objects directly where shown.
Options
16| Name | Type / requirement | Usage |
|---|---|---|
BodyFont | FontPresetOptional | System sans, System serif, System monospace, Inter, Roboto, Source Sans 3, DM Sans, Manrope, Montserrat, Lora, Merriweather, Playfair Display, IBM Plex Mono, JetBrains Mono, or Custom. |
HeadingFont | FontPreset | 'Inherit'Optional | A font preset or Custom; Inherit uses BodyFont. |
BodyFontFamily | stringOptional | Family name for a Custom font. |
HeadingFontFamily | stringOptional | Family name for a Custom font. |
BodyFontUrl | stringOptional | Relative or HTTP(S) font-file URL, including an OutSystems Resource URL. |
HeadingFontUrl | stringOptional | Relative or HTTP(S) font-file URL, including an OutSystems Resource URL. |
BodyFontWeight | stringOptional | CSS weight descriptor: e.g. 400 for static or 100 900 for a variable file. |
HeadingFontWeight | stringOptional | Weight descriptor for the custom URL: 400 or a variable range such as 100 900. |
BodyFallback | stringOptional | CSS fallback family stack while loading or on failure. |
HeadingFallback | stringOptional | CSS fallback family stack while loading or on failure. |
FontFaces | BluFontFace[]Optional | Additional Custom faces: weights, italics or Unicode subsets. |
Scope | 'Page' | 'Container'Optional | Page applies to the application document; Container applies to TargetId or Content. |
TargetId | stringOptional | Container scope uses this element ID, or its Content slot when empty. |
Content | SlotOptional | Content slot: pass a DOM node or a text string. Strings are rendered as text. |
PresetBaseUrl | stringOptional | Defaults to the package's bundled fonts directory. Copy that directory when bundling. |
ExtendedClass | stringOptional | Additional wrapper classes. |
Callbacks
2| Name | Type / requirement | Usage |
|---|---|---|
Loaded | (bodyFamily: string, headingFamily: string) => void | Promise<void>Optional | Reports Loaded body family., Loaded heading family. |
Error | (message: string) => void | Promise<void>Optional | Reports Font failure; fallback remains active. |
Instance methods & properties
3| Name | Signature / type | Usage |
|---|---|---|
element | HTMLElement | Root owned by this instance. Dispose before removing its host. |
update | (patch: Partial<FontProviderOptions>) => void | Apply a partial options update to this instance. |
destroy | () => void | Dispose the instance and its listeners when the view is removed. |
Related data types
Expand a type for its fields and allowed values.
BluFontFace
Additional custom font weights, italics or Unicode subsets. Role must use Custom.
interface BluFontFace {
Role: 'Body' | 'Heading';
Url: string;
Weight?: string;
Style?: 'normal' | 'italic' | 'oblique';
UnicodeRange?: string;
}Callback
type Callback<T extends unknown[] = []> = (...args: T) => void | Promise<void>;CommonOptions
interface CommonOptions {
ExtendedClass?: string;
}FontPreset
type FontPreset = 'System sans' | 'System serif' | 'System monospace' | 'Inter' | 'Roboto' | 'Source Sans 3' | 'DM Sans' | 'Manrope' | 'Montserrat' | 'Lora' | 'Merriweather' | 'Playfair Display' | 'IBM Plex Mono' | 'JetBrains Mono' | 'Custom';Slot
type Slot = Node | string;Use these inputs, events, actions and structures in Service Studio. Names and data bindings are specific to the native Blocks.
Published in Community and Enterprise, with live OutSystems showcases. Leave PresetBaseUrl empty for native bundled presets. Use the separate body and heading settings for custom deployed font Resource URLs, or set an explicit fonts-folder URL. All eleven bundled families and custom Resource loading have been verified.
Included in the planned free BluKavantUI Community edition. The official OutSystems Forge release is coming soon. View Community scope →
@if(nativeUrl)@if(nativeUrl)Open OutSystems showcase ↗@endif@endif- Web runtime
- Supported
- TypeScript
- Supported
- OutSystems
- Supported
Statuses describe the component’s rendered code and interactions. Supply accessible content and follow the component guidance when integrating it.
Accessibility guidance → · Review evidence →Purpose and use
Headless font loading with bundled presets, custom/resource URLs and separate body and heading families.
Keyboard design guidance
Font loading does not move focus or hide content. Choose legible families and weights; retain readable fallback fonts.
See the support status above for review coverage and any limitations.
In your application
Provide useful labels, preserve visible focus, and test the component with your actual content. Use text alongside status colors and check contrast in each state.
Events0No events yet.
Interact with an example to see its events.