Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fluentui/react-text

Package Overview
Dependencies
Maintainers
12
Versions
919
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fluentui/react-text

Text is a typography and styling abstraction component that can be used to ensure the consistency of all text across your application.

  • 0.0.0-nightly050f89bf0020211102.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
111K
increased by11.48%
Maintainers
12
Weekly downloads
 
Created
Source

@fluentui/react-text

WIP 🚧 - These are not production-ready components as we are still in a Beta phase.

The Text component exists to ensure consistency in your application's content by setting fixed sizes and other styles. This package also exports wrappers which ensure your text follows the Fluent design standards of typography.

Usage

To use the Text components in your application, you can start by installing the main package of Fluent UI components:

npm install @fluentui/react-components
import { FluentProvider, Text } from '@fluentui/react-components';

const App = () => (
  <FluentProvider>
    <Text>Fluent UI Text!</Text>
  </FluentProvider>
);

Or by installing only the @fluentui/react-text package. Keep in mind you'll need to install the FluentProvider package as well:

npm install @fluentui/react-text
npm install @fluentui/react-provider
import { FluentProvider } from '@fluentui/react-provider';
import { Text } from '@fluentui/react-text';

const App = () => (
  <FluentProvider>
    <Text>Fluent UI Text!</Text>
  </FluentProvider>
);

Typography wrappers

List of typography variants by sorted descending by size

Wrappers offer an easy way to use text according to the Fluent Design System while also providing semantic code readability.

Below is an example of the Display wrapper vs using the Text component:

import { Text, Display } from '@fluentui/react-text';

const Example = () => (
  <>
    <Text size={1000} weight="semibold">
      This text is styled like a Display variant.
    </Text>
    <Display>This text is also styled like a Display variant.</Display>
  </>
);

As you can see, using the Display wrapper is a lot easier to read and provides a clearer visual of the page's layout.

Semantic elements

By default, Text and all the typography wrappers render a <span> element. You should use the as property to ensure your page has proper semantic elements such as heading or paragraph elements.

<div>
  <Headline as="h1">Headline</Headline>
  <Subheadline as="h2">Subheadline</Subheadline>
  <Text as="p">This is simple example</Text>
</div>

This will result in the following DOM structure:

<div>
  <h1>Headline</h1>
  <h2>Subheadline</h2>
  <p>This is simple example</p>
</div>

API

For more information about the components, please refer to the API documentation.

Migration

For migration information, have a look at the migration guide.

FAQs

Package last updated on 02 Nov 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc