{"id":74,"date":"2024-10-03T12:00:31","date_gmt":"2024-10-03T16:00:31","guid":{"rendered":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/?page_id=74"},"modified":"2025-10-20T10:50:00","modified_gmt":"2025-10-20T14:50:00","slug":"importing-components","status":"publish","type":"page","link":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/handbook\/wp-core\/importing-components\/","title":{"rendered":"Importing Components"},"content":{"rendered":"\n<h2>WordPress Components<\/h2>\n\n\n\n<p>You can reference <a href=\"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/handbook\/components-reference\/core-components\/\">WordPress&#8217; Core Components<\/a> in the&nbsp;<a href=\"https:\/\/github.com\/WordPress\/gutenberg\">Gutenberg GitHub repo<\/a>&nbsp;or in the&nbsp;<a href=\"https:\/\/developer.wordpress.org\/block-editor\/components\/\">Block Editor Handbook<\/a>. Another good reference is the <a href=\"https:\/\/storybook.js.org\/showcase\/wordpress-gutenberg\">Gutenberg Storybook<\/a>.<\/p>\n\n\n\n<p>To import components into your codebase, use the <a href=\"https:\/\/www.npmjs.com\/package\/@wordpress\/components\/v\/18.0.0\"><code>@wordpress\/components<\/code> npm package<\/a>. Detailed instructions and usage can be found in the <a href=\"https:\/\/developer.wordpress.org\/block-editor\/components\/\">Block Editor Handbook<\/a> and the npm directory. Some have been copied here for quick reference.<\/p>\n\n\n\n<h3>Installation<\/h3>\n\n\n\n<p>Install the module<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">npm install @wordpress\/components --save<\/pre>\n\n\n\n<p><em>This package assumes that your code will run in an&nbsp;<strong>ES2015+<\/strong>&nbsp;environment. If you&#8217;re using an environment that has limited or no support for such language features and APIs, you should include&nbsp;<a href=\"https:\/\/github.com\/WordPress\/gutenberg\/tree\/HEAD\/packages\/babel-preset-default#polyfill\">the polyfill shipped in&nbsp;<code>@wordpress\/babel-preset-default<\/code><\/a>&nbsp;in your code.<\/em><\/p>\n\n\n\n<h3><a href=\"https:\/\/www.npmjs.com\/package\/@wordpress\/components\/v\/18.0.0#usage\"><\/a>Usage<\/h3>\n\n\n\n<p>Within Gutenberg, these components can be accessed by importing from the&nbsp;<code>components<\/code>&nbsp;root directory:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/**\n * WordPress dependencies\n *\/\nimport { Button } from '@wordpress\/components';\n\nexport default function MyButton() {\n\treturn &lt;Button&gt;Click Me!&lt;\/Button&gt;;\n}<\/pre>\n\n\n\n<p>Many components include CSS to add style, you will need to add in order to appear correctly. Within WordPress, add the&nbsp;<code>wp-components<\/code>&nbsp;stylesheet as a dependency of your plugin&#8217;s stylesheet. See&nbsp;<a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_enqueue_style\/#parameters\">wp_enqueue_style documentation<\/a>&nbsp;for how to specify dependencies.<\/p>\n\n\n\n<h2><meta charset=\"utf-8\">BU Components<\/h2>\n\n\n\n<p>For ID specific components, hooks, and functions, see <a href=\"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/handbook\/wp-core\/components-reference\/bu-components\/\">BU Block Imports<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress Components You can reference WordPress&#8217; Core Components in the&nbsp;Gutenberg GitHub repo&nbsp;or in the&nbsp;Block Editor Handbook. Another good reference is the Gutenberg Storybook. To import components into your codebase, use the @wordpress\/components npm package. Detailed instructions and usage can be found in the Block Editor Handbook and the npm directory. Some have been copied here [&hellip;]<\/p>\n","protected":false},"author":3670,"featured_media":0,"parent":575,"menu_order":3,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"status-is-a-reserved-term":[],"assignee":[],"_links":{"self":[{"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages\/74"}],"collection":[{"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/users\/3670"}],"replies":[{"embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/comments?post=74"}],"version-history":[{"count":11,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages\/74\/revisions"}],"predecessor-version":[{"id":740,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages\/74\/revisions\/740"}],"up":[{"embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/pages\/575"}],"wp:attachment":[{"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/media?parent=74"}],"wp:term":[{"taxonomy":"status-is-a-reserved-term","embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/status-is-a-reserved-term?post=74"},{"taxonomy":"assignee","embeddable":true,"href":"https:\/\/id-developer-upgrade-58.cms-devl.bu.edu\/gutenberg\/wp-json\/wp\/v2\/assignee?post=74"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}