diff --git a/dev/getting_started/adding_js_and_css/index.html b/dev/getting_started/adding_js_and_css/index.html index dea567cf..985e8842 100644 --- a/dev/getting_started/adding_js_and_css/index.html +++ b/dev/getting_started/adding_js_and_css/index.html @@ -97,7 +97,7 @@ a component is rendered on the page. This is not true for JS and CSS defined in `Media.js/css`, where the linked JS / CSS are rendered as is. --->
Your components may depend on third-party packages or styling, or other shared logic. To load these additional dependencies, you can use a nested Media
class.
This Media
class behaves similarly to Django's Media class, with a few differences:
str
, bytes
, Path
, SafeString
, or a function.*.js
or styles/**/*.css
.Media.extend
to a list, it should be a list of Component
classes.Learn more about using Media.
from django_components import Component
+--> 5. Link additional JS and CSS to a component¤
Your components may depend on third-party packages or styling, or other shared logic. To load these additional dependencies, you can use a nested Media
class.
This Media
class behaves similarly to Django's Media class, with a few differences:
- Our Media class accepts various formats for the JS and CSS files: either a single file, a list, or (CSS-only) a dictonary (see below).
- Individual JS / CSS files can be any of
str
, bytes
, Path
, SafeString
, or a function. - Individual JS / CSS files can be glob patterns, e.g.
*.js
or styles/**/*.css
. - If you set
Media.extend
to a list, it should be a list of Component
classes.
Learn more about using Media.
[project root]/components/calendar/calendar.pyfrom django_components import Component
class Calendar(Component):
template_file = "calendar.html"
@@ -172,4 +172,4 @@
</script>
</body>
</html>
-
Now that we have a fully-defined component, next let's use it in a Django template ➡️.