React DOM 組件
常見組件
所有內建瀏覽器元件都支援一些道具和事件。
這包括特定於 React 的道具,例如 ref
和 dangerouslySetInnerHTML
。
表單元件
這些內建瀏覽器元件接受使用者輸入
它們在 React 中很特別,因為傳遞 value
道具給它們會讓它們受控。
資源和元資料元件
這些內建的瀏覽器元件讓您可以載入外部資源或使用元資料註解文件
它們在 React 中很特別,因為 React 可以將它們呈現在文件標頭中,在資源載入時暫停,並制定其他行為,這些行為會在每個特定元件的參考頁面上說明。
所有 HTML 元件
React 支援所有內建瀏覽器 HTML 元件。這包括
<aside>
<audio>
<b>
<base>
<bdi>
<bdo>
<blockquote>
<body>
<br>
<button>
<canvas>
<caption>
<cite>
<code>
<col>
<colgroup>
<data>
<datalist>
<dd>
<del>
<details>
<dfn>
<dialog>
<div>
<dl>
<dt>
<em>
<embed>
<fieldset>
<figcaption>
<figure>
<footer>
<form>
<h1>
<head>
<header>
<hgroup>
<hr>
<html>
<i>
<iframe>
<img>
<input>
<ins>
<kbd>
<label>
<legend>
<li>
<link>
<main>
<map>
<mark>
<menu>
<meta>
<meter>
<nav>
<noscript>
<object>
<ol>
<optgroup>
<option>
<output>
<p>
<picture>
<pre>
<progress>
<q>
<rp>
<rt>
<ruby>
<s>
<samp>
<script>
<section>
<select>
<slot>
<small>
<source>
<span>
<strong>
<style>
<sub>
<summary>
<sup>
<table>
<tbody>
<td>
<template>
<textarea>
<tfoot>
<th>
<thead>
<time>
<title>
<tr>
<track>
<u>
<ul>
<var>
<video>
<wbr>
自訂 HTML 元素
如果你呈現一個帶有破折號的標籤,例如 <my-element>
,React 會假設你想要呈現一個 自訂 HTML 元素。 在 React 中,呈現自訂元素與呈現內建瀏覽器標籤的方式不同
- 所有自訂元素屬性都會序列化為字串,並總是透過屬性設定。
- 自訂元素接受
class
而不是className
,以及for
而不是htmlFor
。
如果你使用 is
屬性來渲染內建瀏覽器 HTML 元素,它也會被視為自訂元素。
所有 SVG 組件
React 支援所有內建瀏覽器 SVG 組件。這包括
<a>
<animate>
<animateMotion>
<animateTransform>
<circle>
<clipPath>
<defs>
<desc>
<discard>
<ellipse>
<feBlend>
<feColorMatrix>
<feComponentTransfer>
<feComposite>
<feConvolveMatrix>
<feDiffuseLighting>
<feDisplacementMap>
<feDistantLight>
<feDropShadow>
<feFlood>
<feFuncA>
<feFuncB>
<feFuncG>
<feFuncR>
<feGaussianBlur>
<feImage>
<feMerge>
<feMergeNode>
<feMorphology>
<feOffset>
<fePointLight>
<feSpecularLighting>
<feSpotLight>
<feTile>
<feTurbulence>
<filter>
<foreignObject>
<g>
<hatch>
<hatchpath>
<image>
<line>
<linearGradient>
<marker>
<mask>
<metadata>
<mpath>
<path>
<pattern>
<polygon>
<polyline>
<radialGradient>
<rect>
<script>
<set>
<stop>
<style>
<svg>
<switch>
<symbol>
<text>
<textPath>
<title>
<tspan>
<use>
<view>