# 굵게 {#bold}

Source: [React 에디터에 굵게 버튼 추가하기 · Yurich](https://leeyujoo.com/yurich/ko/features/bold/)

Package: [`yurich`](https://www.npmjs.com/package/yurich)

Package version: `0.1.2`

선택한 텍스트를 굵게 강조합니다.

## 직접 확인하기 {#try-it}

예제 문장 중 “Yurich”를 선택하고 **굵게**를 누르세요. `getHTML()` 결과는 `<p>오늘은 <strong>Yurich</strong>를 조금 강조해 봅시다.</p>`입니다. 같은 선택에서 한 번 더 누르면 굵기가 해제됩니다.

## 에디터에 추가하기 {#setup}

`yurich`에서 `Bold`를 가져와 `extensions` 배열에 넣으세요. 툴바 버튼은 `toggleBold`를 실행하고 `useIsActive`로 굵게 상태를 확인합니다.

```tsx
import { EditorContent, EditorProvider, Bold, useEditor, useIsActive } from 'yurich';

export function BoldEditor() {
  const editor = useEditor({
    extensions: [Bold],
    initialValue: "<p>오늘은 Yurich를 조금 강조해 봅시다.</p>",
  });
  const active = useIsActive(editor, 'toggleBold');

  return (
    <EditorProvider editor={editor}>
      <button
        type="button"
        aria-pressed={active}
        onMouseDown={event => event.preventDefault()}
        onClick={() => editor.execute('toggleBold')}
      >
        굵게
      </button>
      <EditorContent ariaLabel="편집기" />
    </EditorProvider>
  );
}
```

## 동작 알아두기 {#behavior}

`Mod+B`로도 실행할 수 있습니다. 커서만 있을 때는 굵기가 적용되지 않습니다. 선택 영역 일부만 굵다면 명령을 실행했을 때 전체가 굵어집니다.

[기능](https://leeyujoo.com/yurich/ko/features/)
