-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Text - README documentation (#19073)
Co-authored-by: tringakrasniqi <[email protected]> Co-authored-by: Makoto Morimoto <[email protected]>
- Loading branch information
1 parent
a7bec08
commit d628c61
Showing
2 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,99 @@ | ||
# @fluentui/react-text | ||
|
||
**React Text component and wrappers for [Fluent UI React](https://developer.microsoft.com/en-us/fluentui)** | ||
> WIP 🚧 - These are not production-ready components as we are still in a Beta phase. | ||
These are not production-ready components and **should never be used in product**. This space is useful for testing new components whose APIs might change before final release. | ||
<!-- TODO: Add link to the new website --> | ||
|
||
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: | ||
|
||
<!-- TODO: Validate if FluentProvider works without theme. If not, which theme should we refer to --> | ||
|
||
```sh | ||
npm install @fluentui/react-components | ||
``` | ||
|
||
```jsx | ||
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: | ||
|
||
```sh | ||
npm install @fluentui/react-text | ||
npm install @fluentui/react-provider | ||
``` | ||
|
||
```jsx | ||
import { FluentProvider } from '@fluentui/react-provider'; | ||
import { Text } from '@fluentui/react-text'; | ||
|
||
const App = () => ( | ||
<FluentProvider> | ||
<Text>Fluent UI Text!</Text> | ||
</FluentProvider> | ||
); | ||
``` | ||
|
||
## Typography wrappers | ||
|
||
 | ||
|
||
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: | ||
|
||
```tsx | ||
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. | ||
|
||
```html | ||
<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: | ||
|
||
```html | ||
<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](https://aka.ms/fluentui-storybook). | ||
|
||
## Migration | ||
|
||
For migration information, have a look at the [migration guide](./MIGRATION.md). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.