UNPKG

@dash-ui/react

Version:

React components and hooks for dash-ui

77 lines (76 loc) 2.21 kB
/// <reference types="react" /> import type { Styles } from "@dash-ui/styles"; /** * A function for creating a React `<style>` component for * inserting Dash styles in SSR. * * @param html - The HTML generated by `renderToStaticMarkup()` or `renderToString()` * @param styles - An instance of `styles()`. Defaults to the default styles instance * in `@dash-ui/styles`. * @param options * @param options.nonce */ export declare function toComponent( html: string, styles?: Styles<any, any>, options?: { nonce?: string; } ): JSX.Element; /** * A React component for injecting SSR CSS styles into Next.js documents * * @param root0 * @param root0.html * @param root0.styles * @param root0.nonce * @example * // _document.js * import React from 'react' * import Document from 'next/document' * import {Style} from '@dash-ui/react/server' * * export default class MyDocument extends Document { * static async getInitialProps(ctx) { * const initialProps = await Document.getInitialProps(ctx) * return { * ...initialProps, * styles: ( * <> * {initialProps.styles} * <Style html={initialProps.html}/> * </> * ), * } * } * } */ export declare function Style({ html, styles, nonce }: StyleProps): JSX.Element; export interface StyleProps { /** * The HTML generated by Next.js, `renderToStaticMarkup()` or `renderToString()` */ html: string; /** * An instance of `styles()`. Defaults to the default styles instance in `@dash-ui/styles`. */ styles?: Styles<any, any>; /** * A nonce for the `<style>` tag. */ nonce?: Styles<any, any>["dash"]["sheet"]["nonce"]; } /** * Creates a Gatsby replaceRenderer for injecting styles generated by Dash on * the server into the Gatsby `<head>` component * * @param styles - An instance of `styles()`. Defaults to the default styles instance * in `@dash-ui/styles`. * @example * // gatsby-ssr.js * exports.replaceRenderer = require('@dash-ui/react/server').createGatsbyRenderer() */ export declare function createGatsbyRenderer( styles?: Styles<any, any> ): <P = any>(props: P) => P; export * from "@dash-ui/styles/server";