# Project structure // UI components

**URL:** <https://forum.elixirforum.com/t/project-structure-ui-components/42435>\
**Category:** Discussions\
**Tags:** architecture, ui\
**Created:** [September 17, 2021, 11:56am UTC](https://forum.elixirforum.com/t/project-structure-ui-components/42435 "2021-09-17T11:56:50Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![eahanson](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/eahanson/32/20895_2.png) [@eahanson](https://forum.elixirforum.com/u/eahanson)\
**Post date:** [September 17, 2021, 1:23pm UTC](https://forum.elixirforum.com/t/project-structure-ui-components/42435/3 "2021-09-17T13:23:34Z")

</div>

In addition to the libraries like [Surface](https://github.com/surface-ui/surface), [Temple](https://github.com/mhanberg/temple), and [LiveComponents](https://hexdocs.pm/phoenix_live_view/Phoenix.LiveComponent.html), you can create your own components using the plain old [render/3](https://hexdocs.pm/phoenix/Phoenix.View.html#render/3) function.

From inside your main template, you can render another template:

`web/controllers/fruit_controller.ex`:

```elixir
defmodule Web.FruitController do
  use Web, :controller

  def index(conn, _params) do
    render(conn, fruit: GroceryStore.all_fruit())
  end
end

```

`web/templates/fruit/index.html.slim` ([slime](https://github.com/slime-lang/slime)):

```elixir
h1 Fruit

= render Web.TableView, "table.html", id: "all-fruit", columns: [{"Name", :name}, [{"Rating", :rating}], data: @fruit

```

`web/views/table_view.ex`:

```elixir
defmodule Web.TableView do
  use Web, :view
end

```

`web/templates/table/table.html.slim`:

```elixir
table id=@id
  thead
    tr
      = for {title, _key} <- @columns do
        th= title

  tbody
    = for datum <- @data do
      tr do
        = for {_title, key} <- @columns do
          td= datum[key]

```

`assets/css/app.sass`:

```elixir
@import "components"

table#all-fruit
  @include data-table($padding: 1rem)

```

`assets/css/components.sass`:

```elixir
@mixin data-table($padding: 0.5rem)
  td, th
    font-size: 14px
    padding: $padding

  th
    background-color: blue

```

So now you’ve got a reusable, parameterized table component to render HTML, and a reusable, parameterized Sass function to render CSS. That should give you a nice combination of reuse and customizability.

---

_[View the full topic](https://forum.elixirforum.com/t/project-structure-ui-components/42435)._
